Skip to content
Advertisement

MySQL: Return a row if all joint table row have the value true

I’ve two tables as following.

The relationship is

What I want is to return for example for table A the record with id 1 which has a relationship with table B where all the values on table B column Delivered as true.

Advertisement

Answer

You can use group by and having:

This doesn’t use table a. If you want all the columns there, you can also use;

The one difference with this query is that it will also return rows in a that have no rows in b at all.

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