sql - Finding rows that do not have a corresponding entry in join table -
i have table joined table b through join-table j. how can access rows table not have corresponding "join" entry in j based on given attribute table b? example:
table a: ------- id table j: ------- a_id b_id table b: ------- id name
say given b.name = "suzie", how can determine rows not have entry in j b_id b.name = "suzie"? feel should simple query, , considered using group by
because seems each entry in a, want determine if b_id you're working (where b.name = "suzie" in case) exists in j each "group" of a_id's. somehow, can't wrap head around this; appreciate push in right direction.
you can where not exists
:
select a.* tablea not exists ( select 1 tablej j join tableb b on b.id = j.b_id j.a_id = a.id , b.name = 'suzie' )
Comments
Post a Comment