用通配符进行过滤

  1. 包含一个字符串
select name from user_form where name like '%z%'
  1. 包含两个字符
selcet name from user_form where name like'%z%' and name like '%s%'
  1. 按顺序包含两个字符串
select name from user_form where name like '%z%s%'

别名

select user_id as id from user_form 

计算并新增

selcet age,count(age*0.5,2) as halfage from user_form

拼接,大写

select id ,upper(concat(left(name,2),left(university,4))) as info from user_form

时间筛选

select id from user_form where year(date)='2021' and month(date)='02'

求和

select sum(age) as sumage from user_form

最大值

select max(age) as max_age from user_form

分组统计

select age ,count(*) from user_form  group by age

最小值

select gread,min(age)as min_age from user_form group by gread

分组统计筛选

select gread from user_form group by gread having sum(age)>100