Font size
WorksheetsWeek 7 Quiz 1 SQL JOINS
Total questions: 10
Worksheet time: 6mins
What is the purpose of a SQL JOIN?
To remove duplicate rows from a table.
To logically combine related columns from two or more distinct tables into a single result set.
To sort the data in a single table.
To add new rows to an existing table.
What is the name of the most common type of join that returns only the rows that have matching values in the specified join columns in both tables?
(a)
In a join operation, what type of key in the 'child table' references the primary key of the 'parent table'?
(a)
What type of join is used to compare rows within the same table, often for querying hierarchical data?
CROSS JOIN
INNER JOIN
SELF JOIN
FULL OUTER JOIN
What is the core function of the ON clause in a JOIN statement?
It filters the rows after the join is completed.
It specifies the tables to be joined.
It defines the relationship by matching primary and foreign key values.
It sorts the final result set.
Which of the following use cases is best suited for an INNER JOIN?
Listing all customers, including those who have not placed an order.
Finding all products, including those not assigned to a category.
Retrieving a list of all employees who have a direct manager.
Showing all products and all customers in one combined list.
A RIGHT JOIN returns all rows from the right table and which of the following?
All matching rows from the left table, with NULLs for non-matches.
Only the rows with non-null values.
Only the rows that have a direct match in the left table.
All rows from both tables, with NULLs for non-matches.
Scenario: A company has a Customers table and an Orders table. A new business requirement is to generate a comprehensive report that lists all customers, regardless of whether they have placed an order, and all orders, even if a customer record is missing. Question: Which type of join would you use to fulfill this specific business requirement?
INNER JOIN
LEFT JOIN
RIGHT JOIN
FULL OUTER JOIN
Scenario: You are analyzing a database for a social media network. You have an Users table and a Followers table. You need to write a query to find all users who have at least one follower and list their follower count. Question: Which join type is most appropriate to combine data from both tables to find this information, as it will only return users with a corresponding record in the Followers table?
INNER JOIN
LEFT JOIN
RIGHT JOIN
FULL OUTER JOIN
Scenario: A school's database has a Students table and a Teachers table. The school's administration wants a list of all students and the classes they are enrolled in. They also want to include any student who is not currently enrolled in any class. Question: Assuming the Students table is the 'left' table in the query, which join type should you use to ensure all students are included in the result, even those without a matching class record?
INNER JOIN
LEFT JOIN
RIGHT JOIN
SELF JOIN
