MySQL - How to get a list of values in Table A that don't exist in Table B?

后端 未结 3 482
借酒劲吻你
借酒劲吻你 2021-01-26 07:51
**Table A**
1
2
3
4
5
6


**Table B**
2
3
5

How can I select for entry IDs that only exist in Table B? In this example, I\'m looking for a query th

3条回答
  •  一个人的身影
    2021-01-26 08:29

    Try

    select value from B where value not in (select value from A)
    

    to get values in B that are not in A.

    To get the opposite (values in A not in B) use

    select value from A where value not in (select value from B)
    

提交回复
热议问题