Mysql一个sql查询语句写法

来源:互联网 发布:我的世界神秘博士js 编辑:程序博客网 时间:2024/05/07 19:39

俺是菜鸟

A表存在一个id字段,B表也存在一个id字段

需要将A表中不存在,B表中存在的记录全部过滤出来

(1) select * from t_website_notemp where id not in(select id from t_website);

 

(2) select t_website_notemp.* from t_website_notemp left join t_website on t_website_notemp.id = t_website.id where t_website.id is NULL;

 

(3) select * from t_website_notemp id where not exists (select id from t_website);

 

至于具体的性能,也不能就说谁就是绝对的高,应该和数据表的大小等有关,不研究了