开发者

fastest way to find non-matching ids from two tables

I have base table with 1000 values. and second temporary table with 100 val开发者_Python百科ues. 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!


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


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

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜