MySQL: Get rows that are not logged in a joined table

tables

I got this 3 tables as shown aboved.

My goal is to get all bits that user 1 (jm) did not put a reaction to.

Currently I have this MySQL code:

select * from bit b LEFT JOIN bit_reaction br ON (br.bitId=b.id AND br.userId != 1)

The problem here is that bit_reaction.id = 2 is being returned since br.userId is not equal to 1. The correct behavior is that it would only return bits with id 2 and 3.

Thanks for the tip!


Source: mysql

Leave a Reply