
Data Structure
Networking
RDBMS
Operating System
Java
MS Excel
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
Select None of the Rows and Columns in MySQL
To display none of the rows and columns, use SELECT NULL and FALSE as in the below syntax −
select null from yourTableName where false;
Let us first create a table −
mysql> create table DemoTable1367 -> ( -> Id int NOT NULL AUTO_INCREMENT PRIMARY KEY, -> FirstName varchar(20) -> ); Query OK, 0 rows affected (0.55 sec)
Insert some records in the table using insert command −
mysql> insert into DemoTable1367(FirstName) values('Chris'); Query OK, 1 row affected (0.20 sec) mysql> insert into DemoTable1367(FirstName) values('David'); Query OK, 1 row affected (0.10 sec) mysql> insert into DemoTable1367(FirstName) values('Bob'); Query OK, 1 row affected (0.10 sec)
Display all records from the table using select statement −
mysql> select * from DemoTable1367;
This will produce the following output −
+----+-----------+ | Id | FirstName | +----+-----------+ | 1 | Chris | | 2 | David | | 3 | Bob | +----+-----------+ 3 rows in set (0.00 sec)
Following is the query to select none of the rows and columns −
mysql> select null from DemoTable1367 where false;
This will produce the following output. Empty set is visible since we have selected none of the rows and columns −
Empty set (0.00 sec)
Advertisements