Home > database >  Help: oracle nested query!
Help: oracle nested query!

Time:10-02

The create table (S
SID varchar2 (10),
SN varchar2 (10),
SCAL varchar2 (10)
);
The create table C (
CID varchar2 (10),
CN varchar2 (10)
);
The create table SC (
SID varchar2 (10),
CID varchar2 (10),
Score number
);
1. The nested query elective course "computer" student number and name
2. The nested query students of greater than 3 door information
3. The nested query students "Ming" elective courses

CodePudding user response:

1, select the s.s id, s.s n from s, c, sc where s.s id=sc. Sid and Arthur c. id=sc. Cid and Arthur c. n='computer';

2, select s. * from (select s.s id stid, count (s.s id) co from s, c, sc where s.s id=sc. Sid and Arthur c. id=sc. The cid group by s.s id) a, s
Where a.c o=3 and a.s tid=s.s id;
C. 3, the select * from s, c, sc where s.s id=sc. Sid and Arthur c. id=sc. Cid and s.s n='Ming';
Please advise,

CodePudding user response:

The select s.s ID, s.s n from s where s.s ID=(select sc. SID from sc where sc. CID=(select cID from c where Arthur c. n='computer'))

Want to pass this way?

But the above statement is wrong. The back of the two nested is right.

CodePudding user response:

Change "=" to In good
It is less efficient than using the EXISTS and associations

CodePudding user response:

Upstairs positive solutions, thank you.
  • Related