Hello everyone.
I have a form with 5 optional inputs, you can select anywhere from 1 of them up to all 5 of them. The more you select the narrower and more specific the SQL select statement will become.
The data will be pulled from 1 to 3 tables depending on what inputs are returned from the form.
I am not sure how to go about this. I have tried a few ways but I feel I am walking blind. Can I build up the SQL statement as I go (based on what input fields are returned)? Can I run multiple SELECT statements and post process the data somehow?
EXAMPLE:
Table (People)
id
name
Table (Fruit)
id
f_people_id
name
Table (Pet)
id
f_people_id
name
If multiple select box 1 returns ('Apple','Orange')
and
If multiple select box 2 returns ('Cat','Dog')
and
If multiple select box 3 does not return anything.
I need to find all People who have all items ('Apple','Orange','Cat','Dog')
However, the multiple select inputs are optional, you only need at least 1 but can have 2 or all 3 returning data.
How should I proceed?