Home > Software engineering >  Query taking all course of the student's name
Query taking all course of the student's name

Time:11-19

Yourself to do the part has been confused, online there are many kinds of answers, I suddenly had a thinking, put down,
The standard answer is picture so
We may have the innermost its meaning is what someone is taking all the course
Bottom in the second layer is to choose the innermost layer from the curriculum (someone to take all courses) is missing, if the person pick up all the class, so this layer lookup is empty, and as long as finish was not chosen, this layer will be output without the person selected courses,
Then look at the outermost layer, the not only exists that is to say there is no output tuples, does not exist? Does not exist a layer of someone without optional course, which is someone pick up the class, the only output the man's student id,
If the man have a class not to choose, in the middle there will have been selected in the layer class information, then the outermost not detected have value, is not the output current monitoring by the tuples (someone) information,

This is a simple understanding, may be linked to holding a tuple to detect a somewhat different, but the meaning is same,
Reserved for personal use only, if there is comment thanks for comments,

CodePudding user response:

Find a SQL works?

Line 4 is a condition, the From behind can not with table or result sets, but with a condition?

CodePudding user response:

 select s.s name from student s where s.s no not in (
The select s1. Sno from student s1 cross join course c1
Where s1. Sno + c1. Cno not in
(select sc. Sno + sc. Cno from sc))

Select sname from student where the student. The sno not in
(select distinct sc1. Sno from
(select * from student s1 cross join course c1) sc1
The left outer join sc on sc1. Sno=sc. Sno and sc1. Cno=sc. Cno
Where sc. Sno is null)


If not consider efficiency, the above two methods should be able to meet the requirements of you,
Is first to find out no students of all course sno, then use the not in rule out, get the students enrolled in all courses
  • Related