mysql 笔记二

来源:互联网 发布:时间自动校准软件 编辑:程序博客网 时间:2024/06/07 03:44
//查询varchar刑
select * from user where name='gaogao';
//价格小于100元
select * from products where price<100;
//价格小于等于100元
select * from products where price<=100;
//查询姓名不是gaogao的
select * from user wherename<>'gaogao'
//查询id 不是10的用户
select * from user whereid<>10;
//用另一个 !=
select * from user where id!=10;
//用between 限定范围
select * from user where id between10 and 20;
前一个是开始值,后一个是结束值
如果将20 和10替换掉,就得不到结果
//空值检查
null
select * from user where phone is null;
//逻辑操作符 and
select * from products where id<100 andprice<50;
查询出前100个价格低于50元的商品
//or
select * from user where id=10 or id=11;
//or与 and  系统会默认调用and
select * from product where (id>100 orid<10) and price =50
//是查询id大于100或者小于10的商品中,价格为50的商品
如果不加()
select * from product where id>100 orid<10 and price=50
解释为 id小于10并且价格为50的商品,获取id大于100的商品
//in在。。。里
select * from user where id in(10.20.30.40);
//not in 不在。。里,,找出与条件不匹配的行
select * from user where id not in (10.20.30);
原创粉丝点击