MySQL MCQs ( Table and Join Operations ) PART 3

Most asked MySQL MCQs focused on Table and Join Operations Output for UGC NET, SET, EMRS, KVS, ISRO, and Assistant Professor exams.


21. Given the following tables, what will be the output of an INNER JOIN?

Customers Table

CustomerID Name City
1 Alice Delhi
2 Bob Mumbai
3 Charlie Kolkata

Orders Table

OrderID CustomerID Product
101 1 Laptop
102 2 Mobile
103 4 Tablet

Query:

SELECT Customers.Name, Orders.Product  
FROM Customers  
INNER JOIN Orders ON Customers.CustomerID = Orders.CustomerID;

A) Returns all customers with their respective orders
B) Returns customers who have placed orders
C) Returns all customers, even if they don’t have an order
D) Returns all orders, even if they don’t have a customer

Answer: B) Returns customers who have placed orders
(Output: Alice - Laptop, Bob - Mobile)


22. What will a LEFT JOIN return when there is no matching row in the right table?

A) NULL values for the right table columns
B) Exclude those rows
C) Return only matching rows
D) Throw an error

Answer: A) NULL values for the right table columns


23. What does the following query return?

SELECT C.Name, O.Product  
FROM Customers C  
LEFT JOIN Orders O ON C.CustomerID = O.CustomerID;

A) Only customers who placed an order
B) All customers, with NULL for those who haven't placed an order
C) All orders, even if they don’t have a customer
D) Only orders with matching customers

Answer: B) All customers, with NULL for those who haven't placed an order


24. Which JOIN returns only unmatched rows from both tables?

A) INNER JOIN
B) LEFT JOIN
C) RIGHT JOIN
D) FULL OUTER JOIN

Answer: D) FULL OUTER JOIN


25. Given two tables, what will be the output of a CROSS JOIN?

Employees Table

EmpID Name
1 Raj
2 Anil

Departments Table

DeptID DeptName
101 HR
102 IT

Query:

SELECT Employees.Name, Departments.DeptName  
FROM Employees  
CROSS JOIN Departments;

A) 2 rows
B) 4 rows
C) 1 row
D) No rows

Answer: B) 4 rows (Each employee gets paired with every department)


26. Which SQL clause is used to filter grouped records?

A) WHERE
B) GROUP BY
C) HAVING
D) ORDER BY

Answer: C) HAVING


27. What will be the result of the following query?

SELECT Customers.Name, Orders.Product  
FROM Customers  
RIGHT JOIN Orders ON Customers.CustomerID = Orders.CustomerID;

A) Only customers who placed an order
B) All customers, even if they haven't placed an order
C) All orders, even if they don’t have a customer
D) Only unmatched customers

Answer: C) All orders, even if they don’t have a customer


28. If there are 5 rows in Table A and 3 rows in Table B, how many rows will a CROSS JOIN return?

A) 5
B) 3
C) 8
D) 15

Answer: D) 15 (5 × 3)


29. What will be the output of the following query?

SELECT Customers.Name, Orders.Product  
FROM Customers  
FULL JOIN Orders ON Customers.CustomerID = Orders.CustomerID;

A) MySQL does not support FULL JOIN
B) Returns only matching records
C) Returns only unmatched records
D) Returns an error

Answer: A) MySQL does not support FULL JOIN (It requires UNION of LEFT JOIN and RIGHT JOIN)


30. Which SQL JOIN returns all records from the left table and matching records from the right table?

A) INNER JOIN
B) LEFT JOIN
C) RIGHT JOIN
D) FULL OUTER JOIN

Answer: B) LEFT JOIN



Comments