本文介紹了如何不選擇其他表中不存在的行的處理方法,對大家解決問題具有一定的參考價值,需要的朋友們下面隨著小編來一起學習吧!
問題描述
我不想選擇其他表中不存在記錄的行
I want to not select rows where record does not exists in other table
我希望不會選擇 LOCATION 表中不存在但存在于 CYCLE_COUNT_REQUEST 中的 3 行
I expect to not select 3 rows where it does not exists on LOCATION table but exist in CYCLE_COUNT_REQUEST
代碼如下
推薦答案
use 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 )
這篇關于如何不選擇其他表中不存在的行的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網!
【網站聲明】本站部分內容來源于互聯網,旨在幫助大家更快的解決問題,如果有圖片或者內容侵犯了您的權益,請聯系我們刪除處理,感謝您的支持!