Home » SQL & PL/SQL » SQL & PL/SQL » How to know that a field is empty ???
How to know that a field is empty ??? [message #20488] Wed, 29 May 2002 01:57 Go to next message
hug
Messages: 6
Registered: May 2002
Junior Member
Hi,

i want to create a SQL query that go in a table and delete all the records that contains a empty field.

For example, I have a table named tb with 3 fields a,b,c.
I want to create a query that delete all the records where the field c is empty (c is a String type).
I have try this thing :
DELETE FROM tb WHERE c=''
or this other thing
DELETE FROM tb WHERE c=' '
or this
DELETE FROM tb WHERE c=null
but it doesn't work ...

So my question is :
How to know in SQL that a field of a table is empty.
Is there a function or a keyword ???

Thanks for response
Hugues
Re: How to know that a field is empty ??? [message #20489 is a reply to message #20488] Wed, 29 May 2002 02:27 Go to previous messageGo to next message
Maaher
Messages: 7065
Registered: December 2001
Senior Member
The correct syntax is:
DELETE FROM tb WHERE c IS null;

Null is the absence of a value, and an absence of a value cannot be compared, even not with another "absence of a value" (i.e. NULL).

MHE
Re: How to know that a field is empty ??? [message #20493 is a reply to message #20488] Wed, 29 May 2002 03:13 Go to previous messageGo to next message
srinivasarao
Messages: 15
Registered: April 2002
Junior Member
hai

delete from tab where c is null;

hope it will work

srinivas
Re: How to know that a field is empty ??? [message #20495 is a reply to message #20488] Wed, 29 May 2002 22:23 Go to previous message
Tariq Zia
Messages: 5
Registered: May 2002
Junior Member
You cann't compair a null value to any column
whenever u delete u write this querry

DELETE FROM TABLE
WHERE COLUMN IS NULL;
Previous Topic: Strange. (please help : urgent)
Next Topic: Finding date processing a tad difficult
Goto Forum:
  


Current Time: Thu Apr 25 08:52:20 CDT 2024