Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Selecting rows which are not null in sql

Tags:

sql

Why doesn't the following code work in SQL

SELECT * 
FROM DATA
WHERE VALUE != NULL;
like image 773
dineshdileep Avatar asked Oct 25 '25 06:10

dineshdileep


2 Answers

we can not Compare null value with = We Special operator to compare null value in sql IS OPERATOR

SELECT * 
FROM DATA
WHERE VALUE is not NULL;

Null is not any Value.Sql consider Null as Unknown/absence of data.

like image 115
Dhaval Avatar answered Oct 27 '25 20:10

Dhaval


The condition you written is not in proper format. If you want to select not null values from your table then you can use the following command

select *from table name where column name IS NOT NULL
like image 20
Rojalin Sahoo Avatar answered Oct 27 '25 20:10

Rojalin Sahoo