david
david

Reputation: 147

how to show record from null column

I have to use from sqlite DB and I insert many data in my sqlite file. now I want execute records that has "NULL". in oder word I want to see records that are "NULL". when I execute this code I nothing get.

    select  * from table1 where ParentID = NULL 
   //or this select  * from table1 where ParentID = 'NULL'

this is my sqlite file :

enter image description here

I want execute folder1 with checking ParentID (I need only check ParentID column)

Upvotes: 1

Views: 56

Answers (4)

UdayKiran Pulipati
UdayKiran Pulipati

Reputation: 6677

You should use IS NULL. (The comparison operators = and <> both give UNKNOWN with NULL on either side of the expression.)

SELECT * FROM table1 WHERE ParentID IS NULL;

Upvotes: 0

KF2
KF2

Reputation: 10171

NULL values represent missing unknown data.By default, a table column can hold NULL values.NULL values are treated differently from other values.

 SELECT * FROM table1 WHERE ParentID IS NULL

Always use IS NULL to look for NULL values.

Upvotes: 2

Joachim Isaksson
Joachim Isaksson

Reputation: 181097

NULL is never equal to anything, including NULL. You need to use IS instead.

SELECT * FROM table1 WHERE ParentID IS NULL 

Upvotes: 6

Lazarus Lazaridis
Lazarus Lazaridis

Reputation: 6029

You have to use the following:

select  * from table1 where ParentID is NULL 

Upvotes: 5

Related Questions