过滤检索——使用where子句指定搜索条件

2016-11-15  本文已影响0人  olivia_ong

基本where子句

select prod_name,prod_price
from products
where prod_price<10;
select prod_name
from products
where prod_name is NULL;

组合where子句

select prod_name,prod_price
from products
where vend_id=1002 or vend_id=1003 and prod_price>=10;//优先处理and
select prod_name,prod_price
from products
where vend_id in (1002,1003)//相当于OR
order by prod_name;
select prod_name,prod_price
from products
where vend_id not in (1002,1003)
order by prod_name;

使用通配符进行过滤

select prod_id,prod_name
from products
where prod_name like '%anvil%';//表示文本中任意位置包含anvil

使用正则表达式进行过滤

select prod_name
from products
where prod_name like '1000';//没有返回
select prod_name
from products
where prod_name like '1000';//返回JetPack 1000
上一篇 下一篇

猜你喜欢

热点阅读