我用 select top 20 * from A表 order by newid(); //从A表随即取出20条 放到B表里去 //下次再取的时候 如果B表里存在 就不取了 //这个SQL语句怎么写? //因为这是随即取的 我不知道怎么写才效率高
[最优解释]
select top 20 * from ( select E_Word,E_HY,E_LAN from A except select E_Word,E_HY,E_LAN from B) as TB order by NEWID()
[其他解释] 给抢了... select top 20 * from a where not exists (select 1 from b where a.E_Word=b.E_Word and a.E_HY =b.E_HY and a.E_LAN=b.E_LAN) order by newid() 1楼的要2005以后才能用 [其他解释] select top 20 * from A表 except select * from B表 order by newid(); [其他解释]
select top 20 * from ( select E_Word,E_HY,E_LAN from A except select E_Word,E_HY,E_LAN from B) as TB where xxx='xxx' order by NEWID()