1. Home
  2. Data Science
  3. SQL for Data Analysis
  4. Table a has 12 rows and table b has 7 rows. SELECT * FROM…

Added 30 Nov -0001

Table a has 12 rows and table b has 7 rows. SELECT * FROM a CROSS JOIN b; is run. How many rows come back?

  1. 84, because a cross join returns every possible pairing of the two row sets Correct answer
  2. 19, because a cross join appends the second table's rows directly onto the first
  3. 12, because only rows of the first table drive the result of the join
  4. 7, because the smaller table determines the number of output rows

Correct answer

A. 84, because a cross join returns every possible pairing of the two row sets

16 views

MCQSEXAM

Explanation

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.

Reference

Asked in: NTS, PPSC IT, Interviews

Preparing for an exam?

Doubts & discussion

Not sure why the answer is A? Ask here and get an explanation.

Ask a doubt about this MCQ

Shown after review. No links please.

More SQL for Data Analysis MCQs

Practise all SQL for Data Analysis MCQs

Similar MCQs