EXCEPT ALL equivalent in MySQL

后端 未结 3 1476
刺人心
刺人心 2021-01-24 01:03

So I have a table called members and another table called group.The leader of the group is also a member

To retrieve members,who are not leaders I did the following code

相关标签:
3条回答
  • 2021-01-24 01:14

    subquery may do, something like:

    SELECT first_name, last_name, rank
    FROM members
    WHERE id NOT IN (
      SELECT leader
      FROM groups 
      WHERE leader = members.id
    )
    

    We need to know your table structure to help you further

    0 讨论(0)
  • 2021-01-24 01:18

    You can try with this scenario.

    SELECT 
            r.col1,r.col2 
    FROM    tabel1 r 
    WHERE ROW ( r.col1,r.col2 ) NOT IN( 
                                  SELECT 
                                      col1,col2 
                                  FROM tabel2 
                                  );
    
    0 讨论(0)
  • 2021-01-24 01:23
    SELECT first_name, last_name, rank
    FROM members 
    LEFT OUTER JOIN groups ON gid=leader
    WHERE leader is null
    

    Not sure if leader or gid is in the groups table. The column that is in the groups table must have a null check in the where clause.

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