I have two tables: photos and photos. Photograph_tags contains a column called photograph_id (id in photos). You can have many tags for one photo. I have a photo associated with three tags: boy, creek and water. However, executing 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 there something wrong with this request?
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
source share