CS FundamentalsEasyGATE CS (PYQ pattern)

P1(id, name, dept): (1,a,10), (2,b,20), (3,c,10). P2(id, name, city): (1,a,X), (2,z,Y), (4,d,Z). How many rows does SELECT * FROM P1 NATURAL JOIN P2 return?

  1. A. 1
  2. B. 2
  3. C. 3
  4. D. 0

Correct answer: A. 1

NATURAL JOIN equates ALL columns with the same name: both id and name. Only (1, a) matches on both; id 2 matches on id but not on name (b vs z), so the result has 1 row, not the 2 rows of a join on id alone.

More DBMS and SQL questions

Exams that ask this topic