版权声明:本文为博主原创文章,转载请注明来源:https://blog.csdn.net/loame_zyq https://blog.csdn.net/loame_zyq/article/details/81513237
1.去重查询
select distinct id,age from table_name; |
2.指定列查询
select id,name from table_name; |
3.语句运算
select id,name,(english+math+chinese) from table_name; |
4.起别名
select id,name,(english+math+chinese) as '语数外总成绩' from table_name; |
5.模糊查询(查询所有姓李的语数外总成绩)
select id,name,(english+math+chinese) as '语数外总成绩' from table_name where name like '李%'; 将所有姓李的语数外总成绩提升60% select id,name,(english+math+chinese)*1.6 as '语数外总成绩' from table_name where name like '李%'; |
6.where查询过滤
between ... and ... | #从...到... |
in () | #显示在in列的值,例如:in(100.200) |
like '' | #模糊查询 |
not like‘’ | #模糊查询 |
is null | #判断是否为空 |
and | #多个条件同时成立 |
or | #多个条件单一成立 |
7.order by排序语句
位于select语句句尾,asc升序,desc降序 |
默认升序
select age from table_name order by age; |
降序
select age from table_name order by age desc; |
8.常用函数
count() #统计 sum() #求和 |