IS DISTINCT FROM allows a NULL aware comparison to test if two values are different

SQL Workbench/J console interface started.
Enter 'exit' to quit.
Enter 'WbHelp' for a list of SQL Workbench/J specific commands
Config directory: C:\users\thomas\.sqlworkbench

postgres> create table answers (id integer not null primary key, answer integer);
Table 'answers' created

postgres> insert into answers
..>   (id, answer)
..> values
..>   (1, null),
..>   (2, 42),
..>   (3, 100);
INSERT INTO answers successful
3 rows affected

postgres> select * from answers where answer <> 42;

id | answer
---+-------
 3 |    100

(1 Row)

postgres> select * from answers where answer is distinct from 42;

id | answer
---+-------
 1 |
 3 |    100

(2 Rows)

postgres>

Back to the SQL Feature Comparison