清空数据表:truncate table copy_information;
显示部分信息:select id,name,age from information;
按条件查询:select * from information where age>25;
改变属性名称:alter table information change brithday birthday;(属性类型一定要加上!!!!!!!!)
模糊查询,’_’表示匹配一个字符,’%’表示匹配一个或多个字符
select id,name,brithday from information where name like ‘_‘;
select name,brithday from information where name like ‘李%’;
分组查询:select *,count(*) from information group by age;
分组查询配合count(*)进行分组统计
排序查询:
升序查询:select * from information order by age asc;
降序查询:select * from information order by age desc;
聚合函数,max(),min(),avg(),sum()
先分组,在对分组信息统计
select max(age) as max_age,min(age) as min_age,avg(age) as avg_age,sum(age) as sum_age group by age;
二次筛选:having
select count() as different_age,max(age) as max_age,min(age) as min_age,avg(age) as avg_age,sum(age) as sum_age from information group by age having count() >=2;
先分组,对分组信息统计,在二次筛选
限制记录:
从第四条记录向下查询三条记录
select * from information limit 3,3;