SQL Query Fields based on selection

  • Joshua Goldberg
  • Topic Author
  • Offline
  • Junior Member
  • Junior Member
More
5 years 4 months ago #119641 by Joshua Goldberg
SQL Query Fields based on selection was created by Joshua Goldberg
Hi Tuan,

Right now I have a SQL Query custom field that allows me to use the contents of one column of one table to populate a dropdown box.
What would be really great is if I could have 2 followup fields that auto-populate data from the row chosen from the dropdown box.

example:
SQL Query: "SELECT charactername as value, character_name as text FROM `ecc_characters` WHERE <...> ORDER by character_name ASC"

This gives me a nice dropdown box when users can select a character name. But in that same row I have other pieces of information I'd like to be auto-populated as a result when they select their character
character_faction, characterID, etc are all in the same row as the name they just selected.
It would be great if once they make their selction, I could have those 2 items automatically grabbed from DB. So what I need is a SQL Query field where I can reference the contents of another field.

This could work another way. Let's say I wanted to slim down the example I gave above. I could have them choose their Faction first, and then do "SELECT charactername as value, character_name as text FROM `ecc_characters` WHERE Faction Like '<reference to faction field in form above>' ORDER by character_name ASC"



Kind regards,

Josh

Please Log in or Create an account to join the conversation.

Moderators: Tuan Pham Ngoc