How to select a specific record from database using where condition?
Answers
Answered by
0
Ok, I think I might be overlooking something obvious/simple here... but I need to write a query that returns only records that match multiple criteria on the same column...
My table is a very simple linking setup for applying flags to a user ...
ID contactid flag flag_type ----------------------------------- 118 99 Volunteer 1 119 99 Uploaded 2 120 100 Via Import 3 121 100 Volunteer 1 122 100 Uploaded 2
etc... in this case you'll see both contact 99 and 100 are flagged as both "Volunteer" and "Uploaded"...
What I need to be able to do is return those contactid's ONLY that match multiple criteria entered via a search form...the contactid's have to match ALL chosen flags... in my head the SQL should look something like:
SELECT contactid WHERE flag = 'Volunteer' AND flag = 'Uploaded'...
My table is a very simple linking setup for applying flags to a user ...
ID contactid flag flag_type ----------------------------------- 118 99 Volunteer 1 119 99 Uploaded 2 120 100 Via Import 3 121 100 Volunteer 1 122 100 Uploaded 2
etc... in this case you'll see both contact 99 and 100 are flagged as both "Volunteer" and "Uploaded"...
What I need to be able to do is return those contactid's ONLY that match multiple criteria entered via a search form...the contactid's have to match ALL chosen flags... in my head the SQL should look something like:
SELECT contactid WHERE flag = 'Volunteer' AND flag = 'Uploaded'...
Similar questions