GATE 2018 CS – Question 22
Consider the following two tables and four queries in SQL.
Book (isbn, bname), Stock (isbn, copies)
Query 1: SELECT B.isbn, S.copies FROM Book B INNER JOIN Stock S ON B.isbn = S.isbn;
Query 2: SELECT B.isbn, S.copies FROM Book B LEFT OUTER JOIN Stock S ON B.isbn = S.isbn;
Query 3: SELECT B.isbn, S.copies FROM Book B RIGHT OUTER JOIN Stock S ON B.isbn = S.isbn;
Query 4: SELECT B.isbn, S.copies FROM Book B FULL OUTER JOIN Stock S ON B.isbn = S.isbn;
Which one of the queries above is certain to have an output that is a superset of the outputs of the other three queries?
Practise this question in The GATE Grind →
Show answer and explanation
Correct answer: (D) Query 4
Explanation
A full outer join contains the inner join result plus the unmatched rows of both sides, so its output includes the outputs of the inner, left outer and right outer joins.
More Relational Model: Relational Algebra, Tuple Calculus, SQL questions
- GATE 2018 CS Q51
- GATE 2015 CS (CS1) Q31
- GATE 2015 CS (CS1) Q61
- GATE 2017 CS (CS1) Q33
- GATE 2017 CS (CS1) Q51
- GATE 2017 CS (CS1) Q56
All Relational Model: Relational Algebra, Tuple Calculus, SQL questions →