如何不选择其他表中不存在的行

时间:2019-04-25 06:16:23

标签: sql-server tsql notin

我不想选择其他表中不存在记录的行

我希望不要选择LOCATION表上不存在但存在于CYCLE_COUNT_REQUEST中的3行

下面的代码

enter image description here

1 个答案:

答案 0 :(得分:0)

使用NOT EXISTS

select *
from CYCLE_COUNT_REQUEST
where not exists (select 1 
                  from LOCATION  )

NOT IN

 select *
    from CYCLE_COUNT_REQUEST
    where NOT IN(select 1 
                      from LOCATION  )
相关问题