SQL Delete values, including NULL

I want to delete all entries that have no notes like "Invalid process" and the other 2 conditions, as follows: -

 DELETE FROM Entry WHERE EmployeeId = 474 AND Entry_Date = '2016-10-01' 
 AND Remarks <> 'Invalid Process'

But the problem here is that it does not delete entries that are NULL as the value. I want to delete everything except notes, like "Invalid process".

+4
source share
2 answers

Add IS NULLcondition. The operator <>cannot check the NULLvalues.

 DELETE FROM Entry WHERE EmployeeId = 474 AND Entry_Date = '2016-10-01' 
 AND (Remarks <> 'Invalid Process' or Remarks IS NULL)
+10
source

You cannot use the '<>' operator when considering NULL. This behavior is defined in the ANSI SQL-92 standard.

use standard syntax to check for NULL - "IS NULL"

DELETE FROM Entry WHERE EmployeeId = 474 AND Entry_Date = '2016-10-01'  AND (: NULL OR Notes < > 'Invalid Process')

0

Source: https://habr.com/ru/post/1663091/


All Articles