You 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
Using union
by itself will strip out duplicates. If you needed to keep duplicates in your query, you could use the ALL
keyword like so: UNION ALL
.