How to select an empty result set in MySQL?

MySQLMySQLi Database

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)
raja
Published on 11-Jan-2019 10:22:34
Advertisements