0
0
MySQLquery~10 mins

Why JOINs combine related tables in MySQL - Test Your Understanding

Choose your learning style9 modes available
Practice - 5 Tasks
Answer the questions below
1fill in blank
easy

Complete the code to select all columns from the employees table.

MySQL
SELECT [1] FROM employees;
Drag options to blanks, or click blank then click option'
A*
Ball
Ceverything
Dcolumns
Attempts:
3 left
💡 Hint
Common Mistakes
Writing 'all' instead of '*'
Using 'columns' which is not valid SQL syntax
2fill in blank
medium

Complete the code to join the employees table with the departments table on department_id.

MySQL
SELECT employees.name, departments.name FROM employees [1] departments ON employees.department_id = departments.department_id;
Drag options to blanks, or click blank then click option'
AUNION
BJOIN
CWHERE
DGROUP BY
Attempts:
3 left
💡 Hint
Common Mistakes
Using WHERE instead of JOIN for combining tables
Using UNION which combines result sets vertically
3fill in blank
hard

Fix the error in the JOIN clause to correctly combine employees and departments.

MySQL
SELECT employees.name, departments.name FROM employees JOIN departments [1] employees.department_id = departments.department_id;
Drag options to blanks, or click blank then click option'
AWHERE
BUSING
CWITH
DON
Attempts:
3 left
💡 Hint
Common Mistakes
Using WHERE instead of ON in JOIN clause
Using WITH which is not valid here
4fill in blank
hard

Fill both blanks to select employee names and their department names using an INNER JOIN.

MySQL
SELECT employees.name AS [1], departments.name AS [2] FROM employees INNER JOIN departments ON employees.department_id = departments.department_id;
Drag options to blanks, or click blank then click option'
Aemployee_name
Bdepartment_name
Cemp_name
Ddept_name
Attempts:
3 left
💡 Hint
Common Mistakes
Using the same alias for both columns
Using unclear or confusing aliases
5fill in blank
hard

Fill all three blanks to create a query that selects employee names, department names, and filters for departments with 'Sales' in the name.

MySQL
SELECT employees.name AS [1], departments.name AS [2] FROM employees JOIN departments ON employees.department_id = departments.department_id WHERE departments.name [3] '%Sales%';
Drag options to blanks, or click blank then click option'
Aemp_name
Bdept_name
CLIKE
DIN
Attempts:
3 left
💡 Hint
Common Mistakes
Using IN instead of LIKE for pattern matching
Not using aliases for selected columns