Joins and changes quiz

  • Admin
  • 1 min read

Nine questions on INNER and LEFT JOIN, subqueries, and writing rows safely.

SQL

Joins and changes quiz

9 questions, instant feedback

Question 1 of 9
Question 1 of 9 What does an INNER JOIN return?
Why this is the answer

INNER JOIN keeps pairs where the join condition is true, so unmatched rows on either side are dropped.

Question 2 of 9
Question 2 of 9 What does a LEFT JOIN keep that an INNER JOIN drops?
Why this is the answer

LEFT JOIN returns every row from the left table, using NULLs for columns of the right table when no match exists.

Question 3 of 9
Question 3 of 9 Which condition belongs in the ON clause of a LEFT JOIN to keep unmatched rows?
Why this is the answer

Conditions on the right table in WHERE turn the join back into an inner join. Put them in ON if unmatched rows must survive.

Question 4 of 9
Question 4 of 9 Why use table aliases?
Why this is the answer

Aliases such as o and c make qualified columns readable, and they are required when both tables have a column with the same name.

Question 5 of 9
Question 5 of 9 What is a correlated subquery?
Why this is the answer

A correlated subquery is evaluated per outer row because it refers to that row's values, which can be slower than a join.

Question 6 of 9
Question 6 of 9 Which statement adds a row?
Why this is the answer

INSERT adds rows. UPDATE changes existing ones, and ALTER TABLE changes the structure.

Question 7 of 9
Question 7 of 9 What happens to UPDATE without a WHERE clause?
Why this is the answer

Without WHERE, the statement applies to the whole table. Run the same predicate as a SELECT first.

Question 8 of 9
Question 8 of 9 Which type should a price column use?
Why this is the answer

Floating point cannot represent most decimal amounts exactly. Store the smallest currency unit as an integer and format for display.

Question 9 of 9
Question 9 of 9 Which statement creates a table?
Why this is the answer

CREATE TABLE defines columns, types and constraints. It is the statement you run once, usually in a migration file.

Your answers stay in this browser. Nothing is sent to a server.