4

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'.

2 Answers 2

10

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)
Sign up to request clarification or add additional context in comments.

Comments

0

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

use the standard syntax for checking NULLs - "IS NULL"

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

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.