您的位置:首页 > 数据库 > MySQL

mysql 笔记二

2013-10-30 11:53 471 查看
//查询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 where
name<>'gaogao'
//查询id 不是10的用户
select * from user where
id<>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 and
price<50;
查询出前100个价格低于50元的商品
//or
select * from user where id=10 or id=11;
//or与 and  系统会默认调用and
select * from product where (id>100 or
id<10) and price =50
//是查询id大于100或者小于10的商品中,价格为50的商品
如果不加()
select * from product where id>100 or
id<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);
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: