To form a union between two tables, use the following syntax:

SELECT column(s)FROM table1WHERE conditions(s)UNIONSELECT column(s) FROM table2WHERE condition(s)ORDER BY column(s); 

The previous syntax shows you how to UNION two queries together. The WHERE clause in each query is optional. The ORDER BY clause is also optional, and can only appear after the last query in the UNION join.

If you want to get all the awards for both managers and players in 1994, execute this query:

SELECT am.playerid, namegiven, awardid, yearid FROM lahmansbaseballdb.awardsmanagers amINNER JOIN lahmansbaseballdb.people p ON p.playerid = am.playerid WHERE yearid = 1994 UNION SELECT ap.playerid, namegiven, awardid, yearid FROM lahmansbaseballdb.awardsplayers ...

Get Learn SQL Database Programming now with the O’Reilly learning platform.

O’Reilly members experience live online training, plus books, videos, and digital content from nearly 200 publishers.