The select t.m ediid, t.m ediname, t.s howunit, sum (t.s howquan) CalQuan, t.p rice, sum (t.a mount) CalAmount
The from amsh_mixdtl t
Inner join amsh_mix mix on mix. Ourid=t.m ainid
where mix. Recipeid in (select a. Recipeid from out_sendmediaddress AD where a. Orderid is not null and AD. Iscancel=0)
Group by t.m ediid, t.m ediname, t.s howunit, t.p rice;
Statement 2:
The select t.m ediid, t.m ediname, t.s howunit, sum (t.s howquan) CalQuan, t.p rice, sum (t.a mount) CalAmount
The from amsh_mixdtl t
Inner join amsh_mix mix on mix. Ourid=t.m ainid
where the exists (select 1 from out_sendmediaddress AD where a. Orderid is not null and AD. Iscancel=0 and mix. Recipeid=a. Recipeid)
Group by t.m ediid, t.m ediname, t.s howunit, t.p rice;
CodePudding user response:
Has no effect on the query results, there is a difference between execution plan;CodePudding user response:
On the efficiency of method 2 May be higherCodePudding user response:
The results do not have what distinction, in originally and exsits are interchangeableCodePudding user response:
1 to fit the data quantity is little, 2 sentences for a large quantity of data is fasterCodePudding user response:
Ouchi outside little use InLittle use Exists
CodePudding user response: