TGViewer
Data Analytics Data Analytics @sqlspecialist ยท 111K subscribers
Post #2452 9.55K
โœ… SQL Joins with Interview Q&A ๐Ÿ”—๐Ÿ’ป

Joins combine data from multiple tables via common columnsโ€”essential for relational databases and analytics in 2025.

1๏ธโƒฃ INNER JOIN
Only matching records from both tables.
SELECT e.name, d.department_name  
FROM employees e
INNER JOIN departments d ON e.dept_id = d.id;

Use: Employee names with their departments.

2๏ธโƒฃ LEFT JOIN (LEFT OUTER JOIN)
All left table rows + matching right; NULLs for no match.
SELECT e.name, d.department_name  
FROM employees e
LEFT JOIN departments d ON e.dept_id = d.id;

Use: All employees, even without departments.

3๏ธโƒฃ RIGHT JOIN (RIGHT OUTER JOIN)
All right table rows + matching left.
SELECT e.name, d.department_name  
FROM employees e
RIGHT JOIN departments d ON e.dept_id = d.id;

Use: All departments, even empty ones.

4๏ธโƒฃ FULL OUTER JOIN
All rows from both; NULLs where no match (PostgreSQL/MySQL supports).
SELECT e.name, d.department_name  
FROM employees e
FULL OUTER JOIN departments d ON e.dept_id = d.id;

Use: Spot unmatched records.

5๏ธโƒฃ SELF JOIN
Table joins itself.
SELECT a.name AS Employee, b.name AS Manager  
FROM employees a
JOIN employees b ON a.manager_id = b.id;

Use: Employee-manager hierarchy.

Real-World Interview Questions + Answers

Q1: What is the difference between INNER and OUTER JOIN?
A: INNER returns only matches; OUTER includes unmatched from one/both tables.

Q2: When would you use LEFT JOIN instead of INNER JOIN?
A: To keep all left table rows, even without right matches.

Q3: How can you find employees who donโ€™t belong to any department?
A: LEFT JOIN + IS NULL filter.
SELECT e.name  
FROM employees e
LEFT JOIN departments d ON e.dept_id = d.id
WHERE d.department_name IS NULL;


Q4: How would you find mismatched data between two tables?
A: FULL OUTER JOIN + IS NULL on either side.

Q5: Can you join more than two tables?
A: Yes, chain JOINs: FROM A JOIN B ON... JOIN C ON...

๐Ÿ’ฌ Tap โค๏ธ for more!
  • โค 27
More from @sqlspecialist
  1. Oct 12, 20268๏ธโƒฃ You receive a dataset with inconsistent date formats. How would you clean it? Sample Aโ€ฆ
  2. Oct 12, 2026๐Ÿ“Š Data Analyst Interview Series โ€” Part 7 Guys, let's continue our Data Analyst Interviewโ€ฆ
  3. Oct 12, 2026๐Ÿš€ ๐—ช๐—ต๐—ถ๐—ฐ๐—ต ๐—ง๐—ฒ๐—ฐ๐—ต ๐—ฆ๐—ธ๐—ถ๐—น๐—น ๐—ช๐—ถ๐—น๐—น ๐—ฌ๐—ผ๐˜‚ ๐— ๐—ฎ๐˜€๐˜๐—ฒ๐—ฟ ๐—ถ๐—ป ๐Ÿฎ๐Ÿฌ๐Ÿฎ๐Ÿฒ? Want to builโ€ฆ
  4. Oct 9, 2026โ€œHere, the data is sorted by the second column in descending order and the first five rowsโ€ฆ
  5. Oct 9, 2026๐Ÿ“Š Data Analyst Interview Series โ€” Part 6 Guys, let's continue our Data Analyst Interviewโ€ฆ
  6. Oct 9, 2026๐Ÿ‡ฎ๐Ÿ‡ณ ๐—š๐—ข๐—ฉ๐—˜๐—ฅ๐—ก๐— ๐—˜๐—ก๐—ง ๐—ข๐—™ ๐—œ๐—ก๐——๐—œ๐—” โ€” ๐—”๐—œ๐—–๐—ง๐—˜ ๐—œ๐—ก๐—ง๐—˜๐—ฅ๐—ก๐—ฆ๐—›๐—œ๐—ฃ๐—ฆ ๐Ÿฎ๐Ÿฌ๐Ÿฎ๐Ÿฒ ๐Ÿš€โ€ฆ
Threads Profile ViewerView any public Threads profile without an account.Open ThreadLook โ†’Writing with AI? Make it sound human.Metric37 rewrites AI drafts so they read naturally. Free AI detector, 1,500 words free.Try Metric37 โ†’