回顾
# 完整的语法结构
select distinct * from 表名
where 分组之前的过滤条件
group by 分组依据
having 分组
order by 字段1 asc,字段2 desc
limit 5,5 从第五条开始往后展示五条
#where 后面的过滤条件可以跟判断符号(>,
# char_length(字段名):查看字段中数据的长度
# concat 连接字符
select concat(name,':',age) from emp;
# 如果连接符号都一样的话可以用concat_ws
select concat_ws(':',name,age,post) from emp;
# group_concat 分组之后进行连接
# 多表查询
inner join # 内连接
left join # 左连接
right join # 右连接
union # 全连接
补充(了解)
exist
EXISTS关字键字表示存在。在使用EXISTS关键字时,内层查询语句不返回查询的记录,
而是返回一个真假值,True或False。
当返回True时,外层查询语句将进行查询
当返回值为False时,外层查询语句不进行查询。
select * from emp where exists (select * from dep where 1=2); # Empty set (0.01 sec)
select * from emp where exists (select * from dep whe