1、使用where子句:
select 表的字段名 from 对应的表名 where 表的字段名;
例子:select prod_name,prod_price from products where prod_price = 2.50;
where子句的位置:在同时使用order by 和 where 子句时,应该让order by 位于 where 之后,否则将会产生错误。
2、where子句操作符:
1)等于:
数值型:select prod_name,prod_price from products where prod_price = 2.50;
字符型:select prod_name,prod_price from products where prod_name = 'fuses';
2)小于:
select pro_name,prod_price from products where prod_price < 10;
3)大于:
select pro_name,prod_price from products where prod_price > 10;
4)小于或等于:
select pro_name,prod_price from products where prod_price <= 10;
5)大于或等于:
select pro_name,prod_price from products where prod_price >= 10;
6)不等于:
select vend_id,prod_name from products where vend_id <> 1003;
select vend_id,prod_name from products where vend_id != 1003;
3、范围值检查:
select 表的字段名 from 对应的表名 where 表的字段名between 数值 and 数值;
例子:select prod_name,pro_price from products where prod_price between 5 and 10;
在使用between时,必须指定两个值--所需范围的低端值和高端值。这两个值必须用and关键字分隔。between匹配范围中所有的值,包括指定的开始值和结束值。
4、空值检查:
select 表的字段名 from 对应的表名 where 表的字段名 is null;
例子:select prod_name from products where prod_name is null;