← LinkedIn Interview Insights

LinkedIn·Data Analyst·Technical Phone Screen·Intermediate

IntermediatePrefer not to say
Apr 2026

Summary

SQL question at LinkedIn, pretty standard stuff, nothing that should've tripped me up but I still managed to second-guess myself halfway through.

Questions Asked (1)

Q1

What is the difference between a JOIN and a UNION in SQL?

Data ModelingTechnical Trade-offs
Author's notes

Knew this cold and still fumbled the explanation a bit.

Create a free account to read the full note

AI HintsAI Generated

Suggested Approach

Start by defining JOIN and UNION in one sentence each, emphasizing their core purposes: JOIN combines columns from related tables horizontally, while UNION stacks rows from similar queries vertically. Then contrast them across key dimensions like purpose, syntax, and result shape, using a simple example to illustrate. Finally, mention practical implications for data analysis, such as performance and use cases.

Pro tip: Mention that UNION removes duplicates by default while UNION ALL retains them, and note that this choice affects performance and result accuracy—showing you understand trade-offs beyond just syntax.

1. Define each operation

Clearly state that JOIN combines columns from two or more tables based on a related column, while UNION combines rows from two or more SELECT statements with the same column structure.

2. Contrast direction and result shape

Explain that JOIN adds columns horizontally (widening the result), whereas UNION adds rows vertically (lengthening the result).

3. Highlight key requirements and variations

For JOIN, mention join types (INNER, LEFT, etc.) and the need for a join condition. For UNION, note that column count and data types must match, and distinguish UNION vs. UNION ALL.

4. Provide a concrete example

Use a simple example, such as joining Customers and Orders to get customer order details, versus unioning two regional sales tables to get a combined list.

5. Discuss practical implications

Touch on performance considerations (e.g., JOINs can be expensive with large tables; UNION ALL is faster than UNION) and typical use cases in data analysis.

Key Points to Mention

  • JOIN combines columns from multiple tables based on a related key; UNION combines rows from multiple queries with the same schema.
  • JOIN requires a join condition (e.g., ON table1.id = table2.id); UNION requires matching column count and compatible data types.
  • JOIN types include INNER, LEFT, RIGHT, FULL OUTER; UNION has UNION (distinct) and UNION ALL (with duplicates).
  • Result shape: JOIN produces a wider table; UNION produces a longer table.
  • Performance: JOINs can be costly with large tables and improper indexing; UNION ALL is generally faster than UNION due to no deduplication.
  • Use cases: JOIN for enriching data with related attributes; UNION for appending similar datasets (e.g., monthly sales from different regions).

AI-generated suggestions, not part of the candidate's original notes. May be inaccurate — verify before relying on them.