SQL Interview Questions
What is the difference between INNER JOIN, LEFT JOIN, RIGHT JOIN, and FULL OUTER JOIN? Explain with examples. Table: Employees EmpID EmpName DeptID 1 Alice 10 2 Bob 20 3 Charlie NULL 4 David 30 Table: Departments DeptID DeptName 10 HR 20 IT 40 Finance 1. INNER JOIN ------------- Returns only the matching rows from both tables. Non-matching rows are excluded. EX: SELECT e.EmpName, d.DeptName FROM Employees e INNER JOIN Departments d ON e.DeptID = d.DeptID; Result: EmpName DeptName Alice HR Bob IT 2. LEFT JOIN (LEFT OUTER JOIN) ------------------------...