select语句的where子句指定搜索条件过滤显示的数据。
(1)使用where子句
在 select 语句中,where子句在from子句之后给出,返回满足指定搜索条件的数据:select prod_name, prod_price from Products where prod_price = 3.49;
#从Products表中检索两个列:prod_name,和prod_price,但条件是只显示prod_price值为3.49的行。
除了上述例子的相等条件判断,where子句还支持以下条件操作符:![de95b91e179d6bcd4408dcd09a6d40bf.png](https://img-blog.csdnimg.cn/img_convert/de95b91e179d6bcd4408dcd09a6d40bf.png)
例如,使用<>操作符(或!=)进行不匹配检查:select vend_id, prod_name from Products where vend_id <> 'DLL01';
#从Products表中显示vend_id,和prod_name ,但条件是vend_id不是DLL01。
再如,使用between操作符可匹配处于某个范围内的值。需要指定范围的端点值:select prod_name, prod_price from Products where prod_price between 5.99 and 9.49;
# 从Products表中显示prod_name, prod_price,但是条件是价格在5.99美元和9.49美元之间 (包括5.99美元和9.49美元)
(2)组合where子句