Skip to content
Advertisement

Mysql how to select only row in same table and same identifier but different value

I have this dataset :

UserPlans table :

how to only select this row (with ID 3) since this data has been deleted but doesn’t have any data with deletedAt = NULL with same userId ?

Advertisement

Answer

You seem to want rows where userid has no other row whose deletedAt is null. If so, you can use not exists and a correlated subquery:

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