Rewriting Not In Sub-Select as Join for Propel

前端 未结 1 565
谎友^
谎友^ 2021-01-24 12:11

Given the following schema:

person:
  id: ~
group:
  id: ~
group_membership:
  person_id: ~
  group_id: ~

I am attempting to find members not w

相关标签:
1条回答
  • 2021-01-24 12:52

    I think this may be a substitute for the sub-query

    SELECT *
    FROM person
    LEFT OUTER JOIN group_membership
      ON person.id = group_membership.person_id
       AND group_id = 1
    WHERE group_membership.person_id is null
    ;
    

    Rows returned where the person_id is null indicate where rows exist in person but not in group_membership

    0 讨论(0)
提交回复
热议问题