postgresql and&or条件在仅一个查询中提供了and和or条件的优点。
语法:
select column1, column2, ..... columnn
from table_name
where [search_condition] and [search_condition]
or [search_condition];
我们来看一下表“employees”,具有以下数据。
查询名字的值为minsu和地址的值为’delhi‘,或者id值大于等8的记录信息,执行以下查询:
select *
from employees
where (name = 'minsu' and address = 'delhi')
or (id>= 8);
得到以下结果 -