陳述句1:
select t.mediid,t.mediname,t.showunit,sum(t.showquan) CalQuan,t.price,sum(t.amount) CalAmount
from amsh_mixdtl t
inner join amsh_mix mix on mix.ourid=t.mainid
where mix.recipeid in(select ad.recipeid from out_sendmediaddress ad where ad.orderid is not null and ad.iscancel=0)
group by t.mediid,t.mediname,t.showunit,t.price;
陳述句2:
select t.mediid,t.mediname,t.showunit,sum(t.showquan) CalQuan,t.price,sum(t.amount) CalAmount
from amsh_mixdtl t
inner join amsh_mix mix on mix.ourid=t.mainid
where exists (select 1 from out_sendmediaddress ad where ad.orderid is not null and ad.iscancel=0 and mix.recipeid = ad.recipeid)
group by t.mediid,t.mediname,t.showunit,t.price;
uj5u.com熱心網友回復:
對查詢結果沒有影響,執行計劃上是有區別的;uj5u.com熱心網友回復:
效率上方法二可能會高些uj5u.com熱心網友回復:
結果沒啥區別,本來in和exsits就是可以互換的uj5u.com熱心網友回復:
陳述句1適合資料量少的,陳述句2對于資料量大的速度更快uj5u.com熱心網友回復:
外大內小用In外小內大用Exists
uj5u.com熱心網友回復:
沒區別
轉載請註明出處,本文鏈接:https://www.uj5u.com/shujuku/112096.html
標籤:開發
上一篇:執行報錯,求指教
下一篇:查詢陳述句求解答
