select * from a where id in (select id from b)
等價于:
for select id from b
for select 8 from a where a.id = b.id
當b表資料必須小于a表資料時,in優于exists
select * from a where exists (select 1 from b where b.id = a.id)
等價于:
for select * from a
for select * from b where b.id = a.id
防止exists優于in
轉載請註明出處,本文鏈接:https://www.uj5u.com/shujuku/29419.html
標籤:MySQL
上一篇:Mysql大資料量分頁優化
