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);
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);
相关文章推荐
- mysql 模糊查询
- mysql字符问题
- mysql 时间操作 下 很强 (转)
- mysql 时间函数 操作 很强 上(转…
- Mysql中查看表的类型InnoDB
- mysql数据库引擎问题汇总
- MySql5.5忘记root密码的解决方法
- MySQL数据库备份命令
- 详解mysql int类型的长度值问题
- 创建存储过程报ERROR 1-64(42000)
- mysql 技术内幕:InnoDB存储引擎
- 安装Navicat for MySQL详细步骤
- MySql学习1
- MySQL中无GROUP BY直接HAVING的问题【转】
- mysql重复字段中 --- 获得最后一次插入的记录
- How to find configuration file MySQL uses?
- MySQL 开启与关闭远程访问
- MySQL数据库创建和表操作
- MySQL 存储过程传参数实现where id in(1,2,3,...)示例
- Mysql数据数据[字节、长度、数据范围]一览表