i've three tables related.
images: id | filename | filesize | ...
nodes: image_id | tag_id
tags: id | name
And i'm using this query to search images containing x tags
SELECT images.* FROM images
INNER JOIN nodes ON images.id = nodes.image_id
WHERE tag_id IN (SELECT tags.id FROM tags WHERE tags.tag IN ("tag1","tag2"))
GROUP BY images.id HAVING COUNT(*)= 2
The problem is that i need to retrieve also all tags contained by the retrieved image, and i need this in the same query.
This the actual query wich search retrieve all tags contained by the image:
SELECT tag FROM nodes
JOIN tags ON nodes.tag_id = tags.id
WHERE image_id = images.id and nodes.private = images.private
ORDER BY tag
How can i mix this two to have only one query?
I need all image table in the results plus the tags of the image. Like: id filename filesize tags
Maybe if is possible concat tags.