Combining SELECT statements with UNION
suggest changeYou can combine the results of two identically structured queries with the UNION keyword.
For example, if you wanted a list of all contact info from two separate tables, authors and editors, for instance, you could use the UNION keyword like so:
select name, email, phone_number
from authors
union
select name, email, phone_number
from editors
UNION by itself removes duplicate rows. To keep duplicates, use UNION ALL.
Found a mistake? Have a question or improvement idea?
Let me know.
Table Of Contents