Home > database >  Two nested select statement
Two nested select statement

Time:10-02

There is a problem, such as 1, select idh, je, XKS, sj from dz where (... Judge conditions), 2, and select newidh from dz where (... Judgment conditions), it is the first select statement in the idh to control within the scope of the second select, that is to say, such as the second five select output value, first select the idh must output in this 5, how to write the nested, two select statements I will write, read a book in the where idh in I don't why, and how is line with idh, sj to columns, two fields of XKS under the idh and je to count,

CodePudding user response:

 SELECT IDH, JE, XKS, SJ 
The FROM DZ D1
The WHERE (... Judge condition)
AND the EXISTS (SELECT NEWIDH
The FROM DZ D2
The WHERE (... Judge condition)
AND D1. IDH=D2. NEWIDH);

CodePudding user response:

 SELECT IDH, JE, XKS, SJ 
The FROM DZ D1
The WHERE (... Judge condition)
AND the EXISTS (SELECT 1
The FROM DZ D2
The WHERE (... Judge condition)
AND D1. IDH=D2. NEWIDH);

CodePudding user response:

And how is line with idh, sj to columns, two fields of XKS under the idh and je to count

Given the sample data and the desired results
  • Related