-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathIS Null and NOT NUll in SQL.txt
More file actions
25 lines (23 loc) · 1.19 KB
/
IS Null and NOT NUll in SQL.txt
File metadata and controls
25 lines (23 loc) · 1.19 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
// Null
Null values represent missing unkhown data.
Null != 0
Is Null :- This used to select only the records with NULL values in the column.
syntax: SELECT stu_id,name,address from student_reg WHERE address IS NULL;
ex: SELECT * FROM student_reg WHERE dob IS NULL;
+------+-------+---------+------+---------+
| s_id | name | address | dob | fees |
+------+-------+---------+------+---------+
| 104 | BIMAl | KTM | NULL | 1001.23 |
+------+-------+---------+------+---------+
IS NOT NULL :- This is used to select only the records with no NULL values in the column.
Syntax: SELECT column_name From table_name WHERE column_name IS NOT NULL;
ex: SELECT * FROM student_reg WHERE dob IS NOT NULL;
+------+---------+---------+------------+-----------+
| s_id | name | address | dob | fees |
+------+---------+---------+------------+-----------+
| 101 | RAM | KTM | 1998-12-15 | 1000.23 |
| 102 | SITA | KTM | 2001-10-11 | 200000.12 |
| 103 | HARI | PKR | 2001-01-12 | 10000.52 |
| 105 | KAMAL | PKR | 1956-12-12 | 100000.12 |
| 106 | SITA KC | PKR | 1998-02-02 | 20000.12 |
+------+---------+---------+------------+-----------+