The Eduladder is a community of students, teachers, and programmers just interested to make you pass any exams. So we help you to solve your academic and programming questions fast.
In eduladder you can Ask,Answer,Listen,Earn and Download Questions and Question papers.
Watch related videos of your favorite subject.
Connect with students from different parts of the world.
Apply or Post Jobs, Courses ,Internships and Volunteering opportunity. For FREE
See Our team
Wondering how we keep quality?
Got unsolved questions? Ask Questions

gate-cse-2015-->View question

Consider the following three table to store student enrollements in different courses. GATE CSE 2015

Student(EnrollNo, Name)
Course(CourseID, Name)
EnrollMents(EnrollNo, CourseID) 
What does the following query do?
SELECT S.Name
FROM Student S, Course C, Enrollments E
WHERE S.EnrollNo = E.EnrollNo AND 
      C.Name = "DBMS" AND
      E.CourseID = C.CourseID AND
      S.EnrollNo IN 
        (SELECT S2.EnrollNo
         FROM Student S2, Course C2, Enrollments E2
         WHERE S2.EnrollNo = E2.EnrollNo AND
               E2.CourseID = C2.CourseID
               C2.Name = "OS")
A=Name of all students who are either enrolled in "DBMS" or "OS" courses
B=Name of all students who are enrolled in "DBMS" and "OS"
C=Name of all students who are either enrolled in "DBMS" or "OS" or both.
D=Non of the above


Asked On2017-07-03 14:11:27 by:milan-ransingh

Taged users:


Likes:
avi738

Dislikes:
Be first to dislike this question
Talk about this  Like  Dislike
View all qusetions
Answers
Answer: (B) 
The above query is an example of nested query i.e. query within a query. Firstly the inner query is solved and then the outer one depending on the result of the inner query.
WHERE IN returns values that matches values in a list or subquery.
WHERE IN is a shorthand for multiple OR conditions.
Here, firstly the inner query is solved. It returns all the Enrollment 
Numbers (SELECT S2.EnrollNo) of students where the students’ enrollment 
number matches with the enrollment number of the courses 
(WHERE S2.EnrollNo = E2.EnrollNo) which have the course IDs whose Course 
Name is “OS” (E2.CourseID = C2.CourseID and C2.Name = “OS”).
Hence all the enrollment IDs are filtered out for the students who are enrolled for the “OS” course.

The outer query works similarly and filters out all the all tuples where 
the Students Enrollment Number matches with the Enrollment Number where the
course ID’s are for the course names “DBMS” 
(S.EnrollNo = E.EnrollNo AND C.Name =”DBMS” AND E.CourseID = C.CourseId) and 
additionally matches with the ones that are returned by the inner query i.e. 
Enrollment Number of students who are enrolled for the course “OS”.
Hence the above queries returns names of all students (SELECT S.Name) who have enrolled for both courses “DBMS” and “OS”.

Hence option (B).

Answerd on:2017-07-04 Answerd By:prajwalamv

Likes:
Be first to like this answer

Dislikes:
Be first to dislike this answer
Talk about this  Like  Dislike

You might like this video:Watch more here

Watch more videos from this user Here

Learn how to upload a video over here



Lets together make the web is a better place

We made eduladder by keeping the ideology of building a supermarket of all the educational material available under one roof. We are doing it with the help of individual contributors like you, interns and employees. So the resources you are looking for can be easily available and accessible also with the freedom of remix reuse and reshare our content under the terms of creative commons license with attribution required close.

You can also contribute to our vision of "Helping student to pass any exams" with these.
Answer a question: You can answer the questions not yet answered in eduladder.How to answer a question
Career: Work or do your internship with us.Work with us
Create a video: You can teach anything and everything each video should be less than five minutes should cover the idea less than five min.How to upload a video on eduladder