Home > database >  Beginners to consult the database query
Beginners to consult the database query

Time:10-05

Three basic table
Student (sno sname sex age department bplace)
Enroll (sno cno grade)
Course (cno cname)


Topic: retrieve Wilson take all the courses
The select cno from course where sno in (select sno from student where sname like 'a %')
Would like to ask about how to complete the answer with the exists, way of thinking, is urgent! Be urgent!

CodePudding user response:

 SELECT cno 
The FROM course AS c
WHERE the EXISTS
(
SELECT 1
The FROM student AS s
WHERE the sname LIKE 'a %'
AND s.s c.s. no no=
)

CodePudding user response:

reference 1/f, gypsy song response:
 SELECT cno 
The FROM course AS c
WHERE the EXISTS
(
SELECT 1
The FROM student AS s
WHERE the sname LIKE 'a %'
AND s.s c.s. no no=
)

Why the results only cno, there is no data below, the first query is should not enroll table?
  • Related