Home > database >  Trouble to help us have a look at, what is the difference between the two queries?
Trouble to help us have a look at, what is the difference between the two queries?

Time:10-04

Statement 1:
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 higher

CodePudding user response:

The results do not have what distinction, in originally and exsits are interchangeable

CodePudding user response:

1 to fit the data quantity is little, 2 sentences for a large quantity of data is faster

CodePudding user response:

Ouchi outside little use In
Little use Exists

CodePudding user response:

  • Related