select语句和where语句结合
select prod_name,prod_id from products where prod_price = 2.50;
这里返回prod_price=2.50的行的prod_name和prod_id列
select * from products where prod_price = 2.50;
这里返回prod_price=2.50的行的所有列
所有小于10美元的商品信息
select * from products where prod_price < 10;
这里注意,order by语句只能位于where语句之后,否则会出现语法错误,比如第二个语句
select * from products where prod_price <= 10 order by prod_price;
select * from products order by prod_price where prod_price <= 10;
where之<>不等于
select vend_id,prod_name from products where vend_id <> 1003;
select vend_id,prod_name from products where vend_id != 1003;类似
这是检索vend_id不是1003的商品信息
where语句对于字符类型的要使用单引号,对于数字型的则不需要,上下两个可以对比;
搜索检查范围 between 必须要有两个边界值,并且包含边界值
select vend_id,prod_name,prod_price from products where prod_price between 5 and 10 order by prod_price;
空值检查
select cust_id,cust_email from customers;
select cust_id from customers where cust_email is null;
网友评论