开发者

i have two tables in my sql database of 1 million records, is there a way to find out the non matching data

i have two large tables in a database.

table 1 with 2 fields rank,name

and

table2 with 2 fields rank,name.

both are of 1 million records.

can you write php sql code to fetch those records which 开发者_JS百科exists in table2 but does not exist in table1.


SELECT *
FROM Table2
WHERE NOT EXISTS (SELECT 1 FROM Table1 WHERE Table1.Rank = Table2.Rank 
AND Table1.Name = Table2.Name)

You didn't state what the key was, or what criteria you wanted, but this should get you going down the right path. This could be slow for large record sets, but again, you didn't say why/what you wanted this for.

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜