I have a few (over 20) tables in MySQL, which describe an item on many different levels (colors, location etc.). The following is an example of "table01"
+----+----------+
| ID | property |
+----+----------+
| 1 | A |
| 1 | B |
| 2 | C |
| 2 | B |
+----+----------+
Now I want to search for items that match multiple criteria. The following query works just fine
SELECT
table01.ID, table01.property, table02.property, table03.property [...]
FROM
table01
LEFT JOIN table02 ON table02.ID = table01.ID
LEFT JOIN table03 ON table03.ID = table01.ID
[...]
WHERE
table01.property = "A"
and table02.property = "B"
and table03.property = "A"
[...]
Heres my problem. I want to search for an item that matches for a few properties in one table. For example (this query obviously does not work)
table01.property = "A" AND table01.property = "B"
I don't know how to achieve that, because the information is stored in multiple rows.
Any suggestions? The database is huge (a few thousand entries per table) and new rows get added from time to time. Should I do some of the processing through PHP or is there a pure MySQL Solution?