0
0
SQLquery~5 mins

INNER JOIN syntax in SQL - Cheat Sheet & Quick Revision

Choose your learning style9 modes available
Recall & Review
beginner
What does INNER JOIN do in SQL?
INNER JOIN combines rows from two tables where the join condition is true, returning only matching rows.
Click to reveal answer
beginner
Write the basic syntax of an INNER JOIN between two tables table1 and table2 on a common column id.
SELECT * FROM table1 INNER JOIN table2 ON table1.id = table2.id;
Click to reveal answer
beginner
Can INNER JOIN return rows where there is no match in the other table?
No, INNER JOIN only returns rows where there is a match in both tables based on the join condition.
Click to reveal answer
intermediate
What happens if you omit the ON clause in an INNER JOIN?
Omitting the ON clause causes a syntax error because the join condition is required to match rows.
Click to reveal answer
intermediate
How is INNER JOIN different from LEFT JOIN?
INNER JOIN returns only matching rows from both tables, while LEFT JOIN returns all rows from the left table and matching rows from the right table (or NULL if no match).
Click to reveal answer
What does INNER JOIN return?
AAll rows from both tables
BAll rows from the left table
CAll rows from the right table
DOnly rows with matching values in both tables
Which keyword is mandatory in an INNER JOIN to specify how tables are matched?
AWHERE
BUSING
CON
DGROUP BY
What happens if there is no matching row in the second table for an INNER JOIN?
AThe row is included with NULLs
BThe row is excluded from the result
CAn error is thrown
DThe row is duplicated
Which SQL clause can be used as a shorthand for INNER JOIN when joining on columns with the same name?
AUSING
BON
CWHERE
DGROUP BY
Which of the following is a valid INNER JOIN syntax?
ASELECT * FROM table1 INNER JOIN table2 ON table1.id = table2.id;
BSELECT * FROM table1 JOIN table2 WHERE table1.id = table2.id;
CSELECT * FROM table1 INNER JOIN table2 USING table1.id = table2.id;
DSELECT * FROM table1 INNER JOIN table2;
Explain how INNER JOIN works and write a simple query joining two tables on a common column.
Think about matching rows in two lists and how you combine them.
You got /3 concepts.
    Describe the difference between INNER JOIN and LEFT JOIN with an example scenario.
    Imagine two lists of friends and which friends appear in both or only one list.
    You got /3 concepts.