2

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?

Mureinik
  • 297,002
  • 52
  • 306
  • 350
BlueGirl
  • 491
  • 2
  • 9
  • 29

1 Answers1

5

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;
Mureinik
  • 297,002
  • 52
  • 306
  • 350
  • Thanks, and I have another question: when we use java to delete from table we have syntax like this: String query = "delete from users where id = ?"; PreparedStatement preparedStmt = conn.prepareStatement(query); preparedStmt.setInt(1, 3); what about this case? – BlueGirl Oct 05 '14 at 07:03
  • 1
    @VahidehTabrizi If you have another question, please post it as a new question. Thanks! – Mureinik Oct 05 '14 at 07:05