How to select from a set of integers in MySQL?

MySQLMySQLi Database

To select from a set of integers, you can use UNION. 

Following is the syntax −

SELECT yourValue1
UNION
SELECT yourValue2
UNION
SELECT yourValue3
UNION
SELECT yourValue4
.
.
.
.
N

Let us implement the above syntax to select from a set of integers in MySQL −

mysql> SELECT 1000
UNION
SELECT 2000
UNION
SELECT 3000
UNION
SELECT 4000
UNION
SELECT 5000
UNION
SELECT 6000
UNION
SELECT 7000;

This will produce the following output −

+------+
| 1000 |
+------+
| 1000 |
| 2000 |
| 3000 |
| 4000 |
| 5000 |
| 6000 |
| 7000 |
+------+
7 rows in set (0.03 sec)
raja
Published on 29-Apr-2019 15:35:25
Advertisements