Questions
2 of 48
1What is a JOIN in MySQL, and why is it used?
2What is the difference between INNER JOIN and OUTER JOIN?
3How do you write a basic INNER JOIN query between two tables?
4What is the purpose of the ON clause in JOIN statements?
5What is the difference between using JOIN and WHERE for joining tables?
6What are LEFT JOIN and RIGHT JOIN, and how do they differ from INNER JOIN?
7What is a CROSS JOIN, and what result does it produce?
8Can you perform a JOIN without using an explicit JOIN keyword (i.e., using WHERE)? Explain.
9What happens when columns in joined tables have the same name? How do you resolve ambiguity?
10What are NATURAL JOINS and why are they generally discouraged in production code?
11Explain FULL OUTER JOIN and why MySQL does not support it directly. How can it be simulated?
12What is a SELF JOIN and when would you use it? Provide an example.
13How can you simulate an INTERSECT or EXCEPT operation using JOINs in MySQL?
14What is an ANTI JOIN and how do you implement it in MySQL?
15How do JOINs differ when using subqueries vs. derived tables?
16Performance & Optimization
17How does MySQL execute JOIN operations internally (nested loop, hash join, etc.)?
18What is the difference between a nested loop join and a hash join? Does MySQL support hash joins?
19How do indexes affect JOIN performance in MySQL?
20How can the EXPLAIN command be used to analyze JOIN performance?
21How do you optimize multi-table joins for better performance in large databases?
22What are multi-table joins, and how many tables can you join in a single query?
23What is the impact of NULL values in join conditions?
24What’s the difference between using USING(column_name) and ON in JOIN statements?
25How do you join a table with itself multiple times using aliases?
26Can you join more than one column in a JOIN condition? Give an example.
27How do you use JOINs with aggregations and conditions in MySQL?
28How to perform aggregations efficiently on joined tables in MySQL?
29How can you join tables and still include rows with no matches (using LEFT JOIN and IS NULL)?
30How can HAVING and WHERE behave differently in queries involving JOINs?
31How do GROUP BY and JOIN interact — what are the common pitfalls?
32Can you join on a calculated or derived value (for example, using a function in the ON clause)?
33How would you join three or more tables to combine customer, order, and payment data?
34What is the difference between joining normalized tables and joining denormalized ones?
35Can JOINs cause duplicate rows in results? How do you eliminate them?
36How would you write a query to find customers who have orders but no payments using JOINs?
37How do INNER JOIN and EXISTS differ logically and in performance?
38Complex & Edge Cases
39How does MySQL handle joins across databases (cross-database joins)?
40Can you JOIN temporary tables with permanent tables? Are there limitations?
41What happens when you join large datasets without appropriate indexes?
42How can you optimize memory and CPU usage when performing multiple JOINs on large tables?
43Explain a situation where replacing JOIN with a subquery improved performance.
44Does MySQL 8.0 support hash joins or batched key access joins? When are they used?
45What improvements to join optimization were introduced in MySQL 8.0 compared to earlier versions?
46How does MySQL handle join buffering and block nested loop joins?
47Can window functions be used along with JOINs? Give an example.
48What’s the difference between lateral derived tables and correlated subqueries in JOIN contexts?
02 / 48

What is the difference between INNER JOIN and OUTER JOIN?

Difference Between INNER JOIN and OUTER JOIN in MySQL

INNER JOIN and OUTER JOIN are both used to combine rows from multiple tables, but they differ in how they handle unmatched rows.

1. INNER JOIN
  1. 1

    • Returns ONLY the rows that have matching values in both tables.

  2. 2

    • Rows without a match in either table are excluded.

  3. 3
  4. 4

    Example:

  5. 5
  6. 6

    SELECT u.id, u.name, o.amount

  7. 7

    FROM users u

  8. 8

    INNER JOIN orders o ON u.id = o.user_id;

  9. 9
  10. 10

    • Output: Only users who have at least one order.

2. OUTER JOIN
  1. 1

    OUTER JOIN returns matching rows plus non-matching rows from one or both tables.

  2. 2
  3. 3

    Types of OUTER JOIN:

  4. 4
  5. 5

    a. LEFT OUTER JOIN (LEFT JOIN)

  6. 6

    • Returns all rows from the left table.

  7. 7

    • Non-matching rows from the right table are filled with NULL.

  8. 8
  9. 9

    b. RIGHT OUTER JOIN (RIGHT JOIN)

  10. 10

    • Returns all rows from the right table.

  11. 11

    • Non-matching rows from the left table are filled with NULL.

  12. 12
  13. 13

    c. FULL OUTER JOIN

  14. 14

    • Returns all rows from both tables (matching + non-matching).

  15. 15

    • MySQL does NOT support this directly but can be simulated using UNION.

Simulating FULL OUTER JOIN in MySQL
3. Key Differences
  1. 1

    • INNER JOIN → Keeps ONLY matching rows.

  2. 2

    • OUTER JOIN → Includes matching rows + non-matching rows.

  3. 3

    • LEFT JOIN → Preserves all rows from the left table.

  4. 4

    • RIGHT JOIN → Preserves all rows from the right table.

  5. 5

    • FULL OUTER JOIN → Preserves all rows from both tables (not directly supported in MySQL).

Difficulty: 3/10
Topics: JOIN types, NULL handling, result set cardinality

Scenario Questions

0-2 years experience
  1. 1

    You're writing a query to list all customers and their orders, but some customers haven't placed orders yet. You used INNER JOIN and now those customers are missing — what’s the fix?

  2. 2

    Your report shows 500 rows after joining users and profiles, but you know there are 600 users. What’s the most likely cause and how would you check?

  3. 3

    You need to find all products that have no sales records. How would you write that query in MySQL and why can't you use INNER JOIN?

2-5 years experience
  1. 1

    A feature that shows user activity with their last payment broke after a data migration — now it’s showing fewer users than before. You suspect the JOIN changed. How do you debug this?

  2. 2

    Your team switched from LEFT JOIN to INNER JOIN to improve performance, but now support is flooded with tickets about missing user data. How do you explain the tradeoff and what would you do differently?

  3. 3

    A dashboard shows inconsistent counts between two reports — one uses LEFT JOIN, the other INNER JOIN on the same tables. How do you investigate and resolve the discrepancy?

5-8 years experience
  1. 1

    You’re optimizing a reporting query that joins 5 large tables and uses multiple OUTER JOINs — it’s taking 12 seconds. How would you approach reducing latency without losing data integrity?

  2. 2

    A legacy system uses FULL OUTER JOINs across sharded tables, but MySQL doesn’t support them natively. How would you redesign this to scale while preserving data completeness?

  3. 3

    An analytics pipeline uses LEFT JOINs to preserve all events, but the result set is exploding in size. How do you balance completeness with performance and storage costs?

8+ years experience
  1. 1

    We’re migrating from PostgreSQL to MySQL and have dozens of queries using FULL OUTER JOIN — what’s your strategy to preserve business logic without breaking downstream systems?

  2. 2

    Two teams rely on the same user-order view: one needs all users (LEFT JOIN), the other only active ones (INNER JOIN). How do you design the data layer to avoid duplication and maintain consistency long-term?

  3. 3

    A critical report uses OUTER JOINs across 10+ microservice tables, causing slow ETLs and inconsistent snapshots. How would you architect a sustainable solution that decouples data consumption from source schema changes?

Follow-up Questions

  • What happens if you join on a column with NULL values?
  • How would you verify you didn't accidentally lose data after switching from LEFT to INNER JOIN?
  • Can you explain why a FULL OUTER JOIN might be expensive in MySQL?