

- Trending Categories
Data Structure
Networking
RDBMS
Operating System
Java
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
MySQL query to get result from multiple select statements?
To get result from multiple select statements, use UNION ALL. Following is the syntax −
select yourValue1 AS anyColumnName UNION ALL select yourValue2 AS yourColumnName . . . . N
Let us implement the above syntax in order to return enumeration of numbers in different rows −
mysql> select 100 AS Number UNION ALL select 1000 AS Number UNION ALL select 10000 AS Number UNION ALL select 100000 AS Number UNION ALL select 1000000 AS Number UNION ALL select 10000000 AS Number UNION ALL select 100000000 AS Number UNION ALL select 1000000000 AS Number;
This will produce the following output -
+------------+ | Number | +------------+ | 100 | | 1000 | | 10000 | | 100000 | | 1000000 | | 10000000 | | 100000000 | | 1000000000 | +------------+ 8 rows in set (0.00 sec)
- Related Questions & Answers
- MySQL query to select multiple rows effectively?
- MySQL select query with multiple WHERE?
- Implement MySQL query using multiple OR statements. Any optimal alternative?
- MySQL query to select date from timestamp?
- How to get a specific column record from SELECT query in MySQL?
- MySQL query to select closest date from today?
- Set user variable from result of query in MySQL?
- MySQL Select Multiple VALUES?
- How can you order the result obtained by select query in MySQL?
- MySQL query to get the highest value from a single row with multiple columns
- Implement case sensitivity in MySQL SELECT statements
- How to get multiple rows in a single MySQL query?
- Insert values from the first table to the second table using two SELECT statements in a single MySQL query
- MySQL query to get result by month and year based on condition?
- How to select first and last data row from a MySQL result?
Advertisements