Table a has 12 rows and table b has 7 rows. SELECT * FROM a CROSS JOIN b; is run. How many rows come back?
Correct answer
A. 84, because a cross join returns every possible pairing of the two row sets
16 views
A. 84, because a cross join returns every possible pairing of the two row sets
16 views
Cross join forms the cartesian product, so m rows joined with n rows produce m*n rows, here 84. A missing join condition in an older comma-style FROM list silently produces exactly this explosion. Adding WHERE a.key = b.key reduces it to the matching pairs, which is what an inner join expresses.
Asked in: NTS, PPSC IT, Interviews
Not sure why the answer is A? Ask here and get an explanation.