Mysql数据库 查询
今天学到了 数据库的几个查询功能:
1.模糊查询
select * from 表名 where 字段 like ‘%w%’; 加了%之后表示后面或者前面必须有文字;
select * from 表名 where 字段 like ‘李_’; 加了_之后表示后面或者前面必须有文字;
2.去重复数据
select distinct 字段1 from 表名;
3.排序 select *from 表名 order by 列名 asc(asc升序默认;desc降序);
4.聚合函数
min最小值; max最大值; sum值的和; count统计行数; avg平局值;
5.分组查询后使用
group by 字段 having
6.分页查询
limit(页码数,显示页数);
7.多表联合查询
select * from 表1 as a join 表2 as b on a.id=b.lid where a.id =3;
left join 左边表的部分显示
right join 右边表的部分显示
8.子查询 select*from 表1 where tid
(select id from表2 where name=‘xx’);
posted on 2020-06-01 17:04 vermouthmo 阅读(172) 评论(0) 收藏 举报
浙公网安备 33010602011771号