MySQL IS NULL & IS NOT NULL

 How to work Null & Not Null:

Syntax:



Code:
CREATE TABLE student( id INT NOT NULL UNIQUE, name VARCHAR(50) NOT NULL, age INT NOT NULL CHECK(age >= 18), gender VARCHAR(1) NOT NULL, phone VARCHAR(10) NOT NULL UNIQUE, city VARCHAR(15) NOT NULL DEFAULT 'MUL' );


Insert Records

INSERT INTO student(id,name,age,gender,phone,city)
VALUES
(1,"Asif","13","M","4022155","BHW"),
(2,"Saqib","21","M","4034421","Mul"),
(3,"Salman Khan","20","M","4056221","Mul"),
(4,"Maryam","18","F","4022155","DG Khan"),
(5,"Hamza","22","M","4025221","Mul"),
(6,"Anela","21","F","4056776","LHR");

IS NULL & NOT NULL

SELECT * FROM student WHERE birth_date IS NULL;

SELECT * FROM student WHERE name IS NULL;

SELECT * FROM student WHERE name NOT NULL;

Comments