UNION / UNION ALL
command
Combines result sets of two or more SELECT statements. UNION removes duplicates; UNION ALL keeps them.
Syntax
SELECT ... UNION [ALL] SELECT ...
Example
sql
-- Active and featured posts
SELECT id, title, 'active' AS status FROM posts WHERE active = 1
UNION
SELECT id, title, 'featured' AS status FROM posts WHERE featured = 1;
-- Keep duplicates
SELECT email FROM users
UNION ALL
SELECT email FROM admins;