How to select an empty result set in MySQL?


Select an empty result set with the help of dummy table ‘dual’ from MySQL. The query is as follows −

mysql> select 1 from dual where false;
Empty set (0.00 sec)

In the above query, “dual” is a dummy table and the above condition false. Therefore, it returns empty set.

Let us check with true condition. It will return the selected value. The query is as follows −

mysql> select 1 from dual where true;

The following is the output −

+---+
| 1 |
+---+
| 1 |
+---+
1 row in set (0.00 sec)

Updated on: 30-Jul-2019

825 Views

Kickstart Your Career

Get certified by completing the course

Get Started
Advertisements