Skip to main content

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

Popular posts from this blog

Top 5 Safe Chat Apps for Kids with Parental Controls

Now a days kids are growing up with technology at their fingertips. While communication apps help children stay connected with family and friends, safety remains a top concern for parents. Unregulated platforms can expose children to inappropriate content, online predators, and cyberbullying. That’s why choosing a kid-friendly chat app with parental controls is essential. To help parents find the best options, we’ve compiled a list of the top five safest chat apps for kids that offer safe and controlled environment. 1. Messenger Kids (By Meta) Best for: Safe video calls and text messaging with parental supervision Features: Parents approve all contacts No ads or in-app purchases Fun filters, stickers, and games Monitored messaging and activity reports Why It’s Safe: Messenger Kids is designed for children under 13 and requires parental approval for every contact. Parents can monitor chats and control screen time through the Parent Dashboard. Download Messenger Kids 2...

10 Routing Protocol MCQ

10 multiple-choice questions on Routing protocol s  with explanations, useful for UGC NET, SET, GATE, ISRO, and other competitive exams . Question 1: Purpose of Routing Protocols Q1: What is the primary purpose of a routing protocol? A) To assign IP addresses to devices B) To determine the best path for data packets to reach their destination C) To encrypt data during transmission D) To physically connect different networks Answer: B) To determine the best path for data packets to reach their destination Explanation: Routing protocols help routers determine the most efficient path for data transmission across a network, ensuring fast and reliable communication. Question 2: Classification of Routing Protocols Q2: Routing protocols can be broadly classified into which two main categories? A) TCP and UDP B) Distance Vector and Link-State C) IPv4 and IPv6 D) Static and Dynamic Answer: B) Distance Vector and Link-State Explanation: Routing prot...

10 Distance Vector and Link-State Routing MCQ

  10 multiple-choice questions  on  Distance Vector and Link-State Routing with explanations, useful for  UGC NET, SET, GATE, ISRO, and other competitive exams . Question 1: Basic Concept of Distance Vector Routing Q1: In a distance vector routing protocol, how do routers share routing information? A) By flooding the entire network with routing updates B) By periodically exchanging routing tables with their immediate neighbors C) By using a link-state database to determine the shortest path D) By dynamically updating paths based on link failure reports Answer: B) By periodically exchanging routing tables with their immediate neighbors Explanation: In Distance Vector Routing, routers share their routing tables with neighbors at regular intervals, leading to a simple but slow convergence mechanism. Question 2: Example of Distance Vector Routing Protocol Q2: Which of the following is an example of a Distance Vector routing protocol? A) OSPF ...