mySql优化in查询


普通查询:

select t1.name,t1.age from table1 t1 
where t1.sid in
(
    select t2.id from table2 t2 where t2.yahei='嘿嘿'
)

优化后sql

select t1.name,t1.age from table1 t1 
where t1.sid in
(
    select t21d from
    (
        select t2.id as t21d from table2 t2 where t2.yahei='嘿嘿'
    ) as t21d
)

 


免责声明!

本站转载的文章为个人学习借鉴使用,本站对版权不负任何法律责任。如果侵犯了您的隐私权益,请联系本站邮箱yoyou2525@163.com删除。



 
粤ICP备18138465号  © 2018-2025 CODEPRJ.COM