[SQL] 查詢兩表中共有的數據

SQL如何找出連接兩表之後,兩表共有的記錄

其實這個問題就是平常

查詢出A表中有但B表中沒有的數據

select * from class1 a
left join student_info b
on a.student_id=b.student_id
where b.student_id is null 

=>

查詢出A表中有但B表中不是沒有的數據 = 查詢出AB兩表中共有數據

select * from class1 a
left join student_info b
on a.student_id=b.student_id
where b.student_id is not null 

上了仨月班感覺直接癡呆 學的沒有忘得快

在這裏插入圖片描述

2020年6月30日18:35:23
到點了,下班回家
在這裏插入圖片描述

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章