UNION Result
Predict Output Medium
Question
What does this SQL produce?
Code
-- Table A: names "X", "Y"
-- Table B: names "Y", "Z"
SELECT name FROM A UNION SELECT name FROM B;
Hint
UNION combines and removes duplicates.
Explanation
UNION combines results from both tables and removes duplicates. A has X, Y; B has Y, Z. Combined unique: X, Y, Z (Y appears once). Result: 3 rows.
Related Resources
Related Lessons
- SELECT
Learn SELECT.
Look up unfamiliar terms
A beginner-friendly glossary explains jargon in plain English — variables, functions, DOM, Promise, and more.
Decode error messages
Plain-English explanations of common errors — what they mean, why they happen, and how to fix them.
Build real projects
Apply what you learned by building guided projects with starter code and solutions.