postgresql not in条件与where子句一起使用,以从指定条件否定in
条件的表中获取数据。
语法:
select column1, column2, ..... columnn
from table_name
where [search_condition] not in [condition];
我们来看一下表“employees
”,具有以下数据。
查询那些年龄不是19
,25
的数据,执行以下查询:
select *
from employees
where age not in (19, 25);
执行上面查询语句,得到以下结果 -
再来看看另外一个例子,查询那些名字不是minsu
,maxsu
的数据信息,执行以下查询:
select *
from employees
where name not in ('maxsu', 'minsu');
执行上面查询语句,得到以下结果 -