mysql_where条件

时间:2022-06-22 16:55:54

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;