Display all data in "ps_games", "xbox_games" and "cube_games" as a single result set
mysql>
mysql>
mysql> CREATE TABLE IF NOT EXISTS ps_games
-> ( code VARCHAR(10), title CHAR(20), ages VARCHAR(3) );
Query OK, 0 rows affected (0.00 sec)
mysql>
mysql> INSERT INTO ps_games (code, title, ages) VALUES ("567/3573", "Crash Bash Platinum", "3+");
Query OK, 1 row affected (0.00 sec)
mysql> INSERT INTO ps_games (code, title, ages) VALUES ("567/0301", "The Italian Job", "11+");
Query OK, 1 row affected (0.00 sec)
mysql>
mysql> CREATE TABLE IF NOT EXISTS xbox_games
-> ( code VARCHAR(10), title CHAR(20), ages VARCHAR(3) );
Query OK, 0 rows affected (0.00 sec)
mysql>
mysql> INSERT INTO xbox_games (code, title, ages) VALUES ("567/2660", "Blinx", "3+");
Query OK, 1 row affected (0.00 sec)
mysql> INSERT INTO xbox_games (code, title, ages) VALUES ("567/0569", "Turok Evolution", "15+");
Query OK, 1 row affected (0.00 sec)
mysql>
mysql> CREATE TABLE IF NOT EXISTS cube_games
-> ( code VARCHAR(10), title CHAR(20), ages VARCHAR(3) );
Query OK, 0 rows affected (0.00 sec)
mysql>
mysql> INSERT INTO cube_games (code, title, ages) VALUES ("567/0428", "Scooby-Doo", "3+");
Query OK, 1 row affected (0.00 sec)
mysql> INSERT INTO cube_games (code, title, ages) VALUES ("567/0411", "Resident Evil", "15+");
Query OK, 1 row affected (0.00 sec)
mysql>
mysql> SELECT * FROM ps_games
-> UNION
-> SELECT * FROM xbox_games
-> UNION
-> SELECT * FROM cube_games;
+----------+---------------------+------+
| code | title | ages |
+----------+---------------------+------+
| 567/3573 | Crash Bash Platinum | 3+ |
| 567/0301 | The Italian Job | 11+ |
| 567/2660 | Blinx | 3+ |
| 567/0569 | Turok Evolution | 15+ |
| 567/0428 | Scooby-Doo | 3+ |
| 567/0411 | Resident Evil | 15+ |
+----------+---------------------+------+
6 rows in set (0.00 sec)
mysql>
mysql> # delete these sample tables
mysql> DROP TABLE IF EXISTS ps_games;
Query OK, 0 rows affected (0.00 sec)
mysql> DROP TABLE IF EXISTS xbox_games;
Query OK, 0 rows affected (0.00 sec)
mysql> DROP TABLE IF EXISTS cube_games;
Query OK, 0 rows affected (0.00 sec)
mysql>
Related examples in the same category