I´m net very good in explaining this. But i do my best:
I've made a tagging tool for people. Some people contains more then 1 tag, and i need to get those but dont know how to write the SQL query for multiple tag inclusion.
I know you can't write WHERE conditions like this:
LOWER( peoples_tags.tag_id ) = 'outside' AND
LOWER( peoples_tags.tag_id ) = 'summer'
Cause each person result is on his own row and 'outside' and 'summer' wont be on the same row. So you don't get any results by using this query.
This is the whole query:
SELECT DISTINCT peoples.*,tags.tag FROM people
JOIN peoples_tags ON peoples_tags.people_id = peoples.id
JOIN tags ON tags.tag = peoples_tags.tag_id AND
LOWER( peoples_tags.tag_id ) = 'outside' AND
LOWER( peoples_tags.tag_id ) = 'summer'
So how do i write a multiple tag SQL condition? Someone knows?
Sorry for my bad english :)