postgresql not条件与where子句一起使用以否定查询中的条件。
语法:
select column1, column2, ..... columnn
from table_name
where [search_condition] not [condition];
我们来看一下表“employees
”,具有以下数据。
查询那些地址不为null
的记录信息,执行以下查询:
select *
from employees
where address is not null ;
得到以下结果 -
再来看另外一个示例,查询那些年龄不是21
和24
的所有记录,执行以下查询:
select *
from employees
where age not in(21,24) ;
得到以下结果 -