mysql 核心笔记 逻辑符号 like

条件查询

*

语法:
	select 
		查询列表
	from
		表名
	where
		筛选条件;

分类:
	一、按条件表达式筛选
	
	简单条件运算符:> < = != <> >= <=
	
	二、按逻辑表达式筛选
	逻辑运算符:
	作用:用于连接条件表达式
		&& || !
		and or not
		
	&&和and:两个条件都为true,结果为true,反之为false
	||或or: 只要有一个条件为true,结果为true,反之为false
	!或not: 如果连接的条件本身为false,结果为true,反之为false
	
	三、模糊查询
		like
		between and
		in
		is null
	
*/
 # 1. 按 条件查询
 eg: select * from employees where salaery > 12000;
# 2.查询部门编号不等于90号的员工和部门编号
    select last_name , department_id from department_id <> 90;
#二、按逻辑表达式筛选
#案例1:查询工资在1000020000之间的员工名、工资以及奖金commission_pct
 select last_name,salary, commission_pct from employees
 where salary >= 10000 and salary <= 10000;
#案例2:查询部门编号不是在90110之间,或者工资高于15000的员工信息
#第一种写法   select  * from employees where department <= 90 or  department >= 110 or salary > 15000;
#第二种写法 
select  * from employees where not (department >= 90 and department <= 110) or salary > 15000;


 

MySQL基础_模糊查询—like关键字 :smile :(注意为:是英文的冒号)

#三、模糊查询

/*
like
between and
in
is null|is not null

*/

mysql 模糊查询 关键字 like

/*
特点:
①一般和通配符搭配使用
通配符:
% 任意多个字符,包含0个字符
_ 任意单个字符
*、

#案例1:查询员工名中包含字符a的员工信息

select * from employees where last_name like ‘%a%’;#abc

# 案列2 查询员工名中第三个字符为e , 第五个字符为a的员工名和工资
select ;ast_name, salary from employees

案例三 查询员工名单中第二字符为——的员工名 ESCAPE 转义字符
select _name from table where _name like '_$_%' ESCAPE '$';

猜你喜欢

转载自blog.csdn.net/liufeifeihuawei/article/details/108404625