fastest way to find non-matching ids from two tables

我的梦境 提交于 2019-12-11 04:29:48

问题


I have base table with 1000 values. and second temporary table with 100 values. I need to compare them by guids and return only those rows from second table that do not exist in first table. I need the fastest performance solution for that. Thanks!


回答1:


The classic left join/isnull test

select A.*
from secondTbl A
left join firstTbl B on A.guid = B.guid
WHERE B.guid is null



回答2:


SELECT * FROM Table2 WHERE 
    NOT EXISTS (SELECT 'x' FROM table1 where 
        table1.field= table2.field)

http://weblogs.sqlteam.com/mladenp/archive/2007/05/18/60210.aspx



来源:https://stackoverflow.com/questions/6528700/fastest-way-to-find-non-matching-ids-from-two-tables

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