用SQL查询两张表上不同的数据语句怎么写?

2025-02-22 10:22:55
推荐回答(3个)
回答1:

如果只是内容上面的更改,那就简单,只要看一下原始表中的最大ID,再找到新表中的此ID,那么比此ID大的就是最新更改的数据。
SQL="Select * from table2 where id not in(select id from table1) order by id desc"

回答2:

select * from newtable where id not in(select top 1 id from oldtable)

回答3:

select * from newtable where id not in(select id from oldtable)