How to exclude records from results when ID from A table is in PID column of B table for the same PUID

こ雲淡風輕ζ 提交于 2021-01-29 07:14:29

问题


How to exclude records from results when ID from A table is in PID column of B table for the same PUIDenter image description here

Table A:

PUID      PID          SYSTEMCODE      ID

100000  701848421         A         3207479

Table B:

PUID    PID        SYSTEMCODE

100000  3207479     B

100000  6805875     B

回答1:


Use not exists:

select a.*
from tablea a 
where not exists (select 1 from tableb b where b.pid = a.id and b.puid = a.puid)


来源:https://stackoverflow.com/questions/64794523/how-to-exclude-records-from-results-when-id-from-a-table-is-in-pid-column-of-b-t

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!