1。查询(select * from 表名)
select
字段列表
from
表名列表
where
条件列表
group by
分组字段
having
分组之后的条件
order by
排序
limit
分页限定
二、基础查询
- 多个字段的查询(如只查询姓名和年龄select name,age from student)查询所有(select * from student)
注:该表为student。 - 去除重复结果(select distinct 列名 from 表名)
- 计算某两个列值计算(select 列名1,列名2,列名1+列名2 from student)
注:如果两列结果有null,则结果会为null
此处如果列名2为null,则上述语句可以写为
“select 列名1,列名2,列名1+ifnull(列名2,0) from student” - 起别名(select 列名1,列名2,列名1+列名2 as 别名 from student)可以使两列名相加后有别的名称