SQL IS NULL Clause
- NULL is a special value that signifies 'no value'.
- Comparing a column to NULL using the = operator is undefined.
- Instead, use WHERE IS NULL or WHERE IS NOT NULL.
The SQL WHERE IS NULL syntax
The general syntax is:
- SELECT column-names FROM table-name WHERE column-name IS NULL
The general not null syntax is:
- SELECT column-names FROM table-name WHERE column-name IS NOT NULL
SQL WHERE IS NULL Examples
1) Example of is null Clause
mysql> select name from person where age is null;
+------+
| name |
+------+
| debo |
| NULL |
| NULL |
+------+
3 rows in set (0.00 sec)
+------+
| name |
+------+
| debo |
| NULL |
| NULL |
+------+
3 rows in set (0.00 sec)
2) Example of Is not null
mysql> select name from person where age is not null;
+-----------------+
| name |
+-----------------+
| subham ball |
| jit |
| sajal |
| sourav biswas |
| sajal |
| chayan das |
| shantanu biswas |
| sudip saha |
| mono |
| monojit |
+-----------------+
10 rows in set (0.00 sec)
+-----------------+
| name |
+-----------------+
| subham ball |
| jit |
| sajal |
| sourav biswas |
| sajal |
| chayan das |
| shantanu biswas |
| sudip saha |
| mono |
| monojit |
+-----------------+
10 rows in set (0.00 sec)
Comments
Post a Comment