码迷,mamicode.com
首页 > 数据库 > 详细

mysql_where条件

时间:2020-02-04 15:30:41      阅读:92      评论:0      收藏:0      [点我收藏+]

标签:mysql   style   条件   bsp   直接   and   pos   等于   code   

where字句中可以使用:

1. 比较运算符:> < >= <= <> !=
2. between 80 and 100 值在10到20之间
3. in(80,90,100) 值是10或20或30
4. like ‘egon%‘
    pattern可以是%或_,
    %表示任意多字符
    _表示一个字符
5. 逻辑运算符:在多个条件直接可以使用逻辑运算符 and or not

 

1.但条件查询

# 查询id大于7的记录。
select * from employee where id > 7

2.多条件查询

# 查询post为teacher 并且 salary 大于8000的记录。
select * from employee where post = teacher and salary > 8000;

3.关键字between and

# 查询salary大于等于20000和salary小于等于30000的记录。
select * from employee where salary between 20000 and 30000;

4.关键字not

# 查询id不大于7的记录。
select * from employee where not id >7;

 

mysql_where条件

标签:mysql   style   条件   bsp   直接   and   pos   等于   code   

原文地址:https://www.cnblogs.com/wangdianchao/p/12259529.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!