Search code examples
javamysqlsqlsqlyog

deleting rows in sqlyog having null values


I have a table which dosen't have any key(foreign key and...). Some of table fields have null value. when I use the command:

DELETE FROM `woe300websnt` WHERE (Arg1=NULL AND Rel=NULL  AND Arg2=NULL);

the query is run successfully but when I use

select * from woe300websnt 

I see that no change is applied and these rows are remained. what is wrong with me?


Solution

  • null is not a value - it's the absence of a value. You cannot use the = operator on it, you need to use the is operator instead:

    DELETE FROM woe300websnt 
    WHERE Arg1 IS NULL AND Rel IS NULL AND Arg2 IS NULL;