Code Bye

求一个效率高的SQL 谢谢啦.


SQL新手,讨教怎么写才效率好,表结构没办法改了,只能在SQL上想想办法谢谢啦
解决方案

5

select
from A
where exists(select 1 from B where a.id = b.id and b.zhizhuangtai=4 )
and a.zhuangtai = 1

5

SELECT DISTINCT(a.ID), a.zhuangtai FROM a LEFT JOIN b ON a.ID = b.ID WHERE a.zhuangtai = “1” AND b.zhuangtai = “4”
LZ试试这个,望采纳

30

select *
from a
where a.zhant=1 and not exists (select 1 from b where id=a.id and b.zt!=4)

CodeBye 版权所有丨如未注明 , 均为原创丨本网站采用BY-NC-SA协议进行授权 , 转载请注明求一个效率高的SQL 谢谢啦.