Mysql - query where ALL search criterias has to be found in second table
Posted on 2010-01-04
I im building a php/mysql based property search.
Tabel one (t1) contains all fields with just one value (title, address etc.). Table two (t2) keeps multiple records for each t1.id.
Table 2 structure:
id t1.id ext.id
In the searchform there are checkboxes for all possible ext.ids and I need to only return results where ALL checked values (ext.ids) is found in t2.
Power (ext.id = 2)
Cabel TV (ext.id = 5)
Garage (ext.id = 6)
Garden (ext.id = 10)
Now I need to pick up the records in t1 where all these ext.ids are found in t2.
Any suggestions on how to build a mysql query for this?
Thanks in advance!