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.
精彩评论