Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

SQL Delete values including NULL

Tags:

sql

sql-server

I want to delete all the records which don't have Remarks as 'Invalid Process' & other 2 conditions as below code :-

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

But problem here is it doesn't delete the records which have NULL as value. I want to delete all except Remarks as 'Invalid Process'.

like image 968
Anup Avatar asked Dec 24 '22 22:12

Anup


1 Answers

Add IS NULL condition. <> operator cannot check NULL values

 DELETE FROM Entry WHERE EmployeeId = 474 AND Entry_Date = '2016-10-01' 
 AND (Remarks <> 'Invalid Process' or Remarks IS NULL)
like image 184
Pரதீப் Avatar answered Dec 27 '22 06:12

Pரதீப்