
- 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
Can we use SELECT NULL statement in a MySQL query?
Yes, we can use the SELECT NULL statement in a MySQL query. Let us first create a table −
mysql> create table DemoTable ( Name varchar(100) ); Query OK, 0 rows affected (0.49 sec)
Insert some records in the table using insert command −
mysql> insert into DemoTable values('Chris'); Query OK, 1 row affected (0.47 sec) mysql> insert into DemoTable values('Mike'); Query OK, 1 row affected (0.23 sec) mysql> insert into DemoTable values('Sam'); Query OK, 1 row affected (0.19 sec) mysql> insert into DemoTable values('Bob'); Query OK, 1 row affected (0.27 sec) mysql> insert into DemoTable values('David'); Query OK, 1 row affected (0.11 sec)
Display all records from the table using select statement −
mysql> select *from DemoTable;
This will produce the following output −
+-------+ | Name | +-------+ | Chris | | Mike | | Sam | | Bob | | David | +-------+ 5 rows in set (0.00 sec)
Following is the query to implement SELECT NULL −
mysql> select null from DemoTable where Name='Mike';
This will produce the following output −
+------+ | NULL | +------+ | NULL | +------+ 1 row in set (0.00 sec)
- Related Articles
- How to use NULL in MySQL SELECT statement?
- How can we check for NULL in a MySQL query?
- How can we use MySQL SELECT statement to count number of rows in a table?
- Can we use ORDER BY NULL in MySQL?
- How can we use group functions with non-group fields in MySQL SELECT query?
- Can we use “LIKE concat()” in a MySQL query?
- How can we use SET statement to assign a SELECT result to a MySQL user variable?
- How to use prepared statement for select query in Java with MySQL?
- Can we use a comma between MySQL SELECT statements?
- How can we use a MySQL subquery with INSERT statement?
- How can I use MySQL IF() function within SELECT statement?
- Can we use WHERE, AND & OR in a single MySQL query?
- How can we use SIGNAL statement with MySQL triggers?
- Can we use WHERE clause inside MySQL CASE statement?
- How can we use MySQL SELECT without FROM clause?

Advertisements