Skip to content
Advertisement

Select rows from table with tag a or b and c

I have a table with objects, a table with tags and a linking table.

The statement without the second condition works, but the out commented one yields no results, this probably because objects_tags.id_tag cannot be two different numbers at the same time.

Is there a way to select all the entries in objects which are linked to tags with ID 3 or 4 and 6?

Advertisement

Answer

I would recommend group by and having:

Note that you only need the object_tags table for this query, because the query is only using ids. If you want additional information, then joins may be necessary.

User contributions licensed under: CC BY-SA
2 People found this is helpful
Advertisement