Create view for union constants
mysql>
mysql> CREATE VIEW DIGITS AS
-> SELECT 0 DIGIT UNION SELECT 1 UNION
-> SELECT 2 UNION SELECT 3 UNION
-> SELECT 4 UNION SELECT 5 UNION
-> SELECT 6 UNION SELECT 7 UNION
-> SELECT 8 UNION SELECT 9
-> ;
Query OK, 0 rows affected (0.00 sec)
mysql> SELECT * FROM DIGITS;
+-------+
| DIGIT |
+-------+
| 0 |
| 1 |
| 2 |
| 3 |
| 4 |
| 5 |
| 6 |
| 7 |
| 8 |
| 9 |
+-------+
10 rows in set (0.00 sec)
mysql>
mysql> drop view digits;
Query OK, 0 rows affected (0.00 sec)
mysql>
Related examples in the same category