How to delete a row in SQL based on a NULL condition

null, sql

Solution

According SQL 92 standard many logical operations with null values like

   > null
   = null
  and null
   or null
  not null

should always return null (and never true). Some DBMS (e.g. Oracle) follow this rule rigorously, some (MS SQL) can have a mode that `null = null` returns true, not required null. In order to be compartible with SQL 92 and so with (almost) all DBMSs, you should use `is null` or `is not null` standard comparisons, in your case

  delete from employee 
        where city is null -- <- Standard comparison 

Problem

I just started learning SQL; I've created a table. Learned insert command and inserted values in 2 rows. However I've inserted null values in 3rd. Now I want to delete the third row which has 2 columns with no values in it. I'm using the following query: ``` delete employee where city=null; ``` It doesn't seem to be working!

Original source

Related problems