p)分组 group by select [xxx] from 表名 group by 字段名
把用户按年龄分组,并统计每个小组的用户个数select count(*), age from t_user group by
age; 分组条件 having
Having和where的区别Having对分组之后的数据进行筛选Where对分组之前的数据进行筛选 例子:A.
m)去掉重复的distinct:select distinct name from t_person;
例子:列出当前系统中拥有的设备种类,不包括重复的Select distinct type from t_device
n)limit:select * from t_user limit of...
f)模糊查询: Where name=”zhangsan” 查询user_name包含“san”的所有记录select *
from t_user where 字段名 like '%san%'; Where name like “%a”
例子:查询姓张的用户Select * from t_user...
f)模糊查询: Where name=”zhangsan” 查询user_name包含“san”的所有记录select *
from t_user where 字段名 like '%san%'; Where name like “%a”
例子:查询姓张的用户Select * from t_user...