
- Learn MySQL
- MySQL - Home
- MySQL - Introduction
- MySQL - Installation
- MySQL - Administration
- MySQL - PHP Syntax
- MySQL - Connection
- MySQL - Create Database
- MySQL - Drop Database
- MySQL - Select Database
- MySQL - Data Types
- MySQL - Create Tables
- MySQL - Drop Tables
- MySQL - Insert Query
- MySQL - Select Query
- MySQL - Where Clause
- MySQL - Update Query
- MySQL - Delete Query
- MySQL - Like Clause
- MySQL - Sorting Results
- MySQL - Using Join
- MySQL - NULL Values
- MySQL - Regexps
- MySQL - Transactions
- MySQL - Alter Command
- MySQL - Indexes
- MySQL - Temporary Tables
- MySQL - Clone Tables
- MySQL - Database Info
- MySQL - Using Sequences
- MySQL - Handling Duplicates
- MySQL - SQL Injection
- MySQL - Database Export
- MySQL - Database Import
How to select from a set of integers in MySQL?
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)
- Related Articles
- How to select an empty result set in MySQL?
- Set MySQL select in a custom variable
- How to select from table where conditions are set for id and name in MySQL?
- How to select date from timestamp in MySQL?
- How to select most recent date out of a set of several possible timestamps in MySQL?
- How to select a random record from a MySQL database?
- Select with set order in MySQL
- How to select first 10 elements from a MySQL database?
- Adding integers from a variable to a MySQL column?
- How to set two variables in a stored procedure with a single MySQL select statement?
- How to select all distinct filename extensions from a table of filenames in MySQL?
- How to select last 10 rows from MySQL?
- How to get a specific column record from SELECT query in MySQL?
- Can we set a single value in MySQL SELECT IN()?
- How to select domain name from email address in MySQL?

Advertisements