天天看点

多表联查更新sql语句如何优化key1:key2:

多表联查更新sql语句如何优化key1:key2:

key1:

SELECT a.sid from (select sid from tb_stu where 1=1 ORDER BY id DESC) a INNER join tb_award b on a.sid+0=b.stu_sid+0           

key2:

SELECT sid  FROM tb_stu A where exists (select stu_sid as sid from tb_award B where B.stu_sid+0 = A.sid+0 group by B.id) ORDER BY A.id;           

这是现在的方案一和方案二,但是实在太慢了。

希望大佬可以提个优化建议。