Consider two database tables, Reports
and Reports_has_properties
Reports
------
id_report
1
2
3
Reports_has_properties
----------------------
id_report property
1 red
1 big
2 orange
3 blue
3 tiny
Problem: I only get only the reports with the property red, for example, but the query returns all the id_report
that match with id_report
SELECT * FROM reports
INNER JOIN reports_has_properties
ON reports_has_properties.id_report = reports.id_report
WHERE reports_has_properties.property = 'red'
The logical explanion is: IF reports_has_properties HAS AN id_report with another property, dont' select it! The id_report 1 hast the property red and big, so isn't good. But if I search for the property orange, the id_report 2 only have one property, so it's ok.
I tried a lot of things but I have no more ideas. Thanks a lot.