Retrieve NULL value : Null « Data Type « SQL / MySQL






Retrieve NULL value

   
/*
mysql> select * from Student;
+-----------+------------+-----------+
| StudentID | first_name | last_name |
+-----------+------------+-----------+
|         1 | John       | Jones     |
|         2 | NULL       | Burton    |
|         3 | Emily      | Scarlett  |
|         4 | Bruce      | Lee       |
|         5 | Anna       | Wolff     |
|         6 | Vic        | Andrews   |
|         7 | NULL       | Alaska    |
+-----------+------------+-----------+
7 rows in set (0.01 sec)

mysql> select * from Student WHERE first_name IS NULL;
+-----------+------------+-----------+
| StudentID | first_name | last_name |
+-----------+------------+-----------+
|         2 | NULL       | Burton    |
|         7 | NULL       | Alaska    |
+-----------+------------+-----------+
2 rows in set (0.02 sec)


*/
Drop table Student;

CREATE TABLE Student (
   StudentID INT NOT NULL PRIMARY KEY,
   first_name      VARCHAR(50),
   last_name      VARCHAR(50) NOT NULL
   
)TYPE = InnoDB;


INSERT INTO Student (StudentID,first_name, last_name) VALUES (4,'Bruce', 'Lee');

INSERT INTO Student (StudentID,first_name, last_name) VALUES (1,'John', 'Jones');
INSERT INTO Student (StudentID, last_name) VALUES (2, 'Burton');
INSERT INTO Student (StudentID, last_name) VALUES (7, 'Alaska');
INSERT INTO Student (StudentID,first_name, last_name) VALUES (5,'Anna', 'Wolff');
INSERT INTO Student (StudentID,first_name, last_name) VALUES (6,'Vic', 'Andrews');
INSERT INTO Student (StudentID,first_name, last_name) VALUES (3,'Emily', 'Scarlett');

select * from Student;

select * from Student WHERE first_name IS NULL; 

           
         
    
    
  








Related examples in the same category

1.Concatenate string with NULL value
2.Working with NULL Values
3.Use the IS NULL and IS NOT NULL operators
4.NULL means 'not having a value'
5.Disallowing NULLs
6.Retrieve NOT NULL value
7.List NOT NULL value and order it
8.Select NOT NULL value
9.IS NOT NULL in where clause
10.NULL value in where clause
11.Read NULL value
12.Dealing With NULL Data
13.An important one to note; the result is not 0 (false), it's NULL
14.To evaluate NULL rows
15.NULL is basically a third possible result of an evaluation: There's true, false, and then there's NULL.
16.Use the IS NULL (or IS NOT NULL) comparison instead
17.Assuming that NULL values sort ahead of all non-NULL values
18.Passing a NULL value to a function results in a NULL return value.
19.Set value to null
20.What is the result of the calculation 10 divided by 0?
21.If the value of an expression cannot be determined, the result is NULL: