I have two tables: photographs, and photograph_tags. Photograph_tags contains a column called photograph_id (id in photographs). You can have many tags for one photograph. I have a photograph row related to three tags: boy, stream, and water. However, running the following query returns 0 rows
SELECT p.*
FROM photographs p, photograph_tags c
WHERE c.photograph_id = p.id
AND (c.value IN ('dog', 'water', 'stream'))
GROUP BY p.id
HAVING COUNT( p.id )=3
Is something wrong with this query?
My tables look like so
-----------------------
photographs
-----------------------
id | title | location
------------------------
7 | asdf | c:\...
-----------------------
photograph_tags
-----------------------
id | photograph_id | value
1 | 7 | dog
2 | 7 | water
3 | 7 | stream
4 | 7 | mountains
I want to pull all photograph rows that relate to at least all three of the searched tags