1、新建表create table create table Person3(Number varchar(20),Age int) 2、数据插入insert into insert into Person3(number,name) values('IT001','小明') 3、数据更新(修改)update set update Person3 set age=30 4、数据检索select select * from Person3 select number as 编号,NAME as 姓名,Salary+10000 as 月薪from Person3;-- as 用来给列名起别名 5、聚合函数 count()、max()、min()、avg()、sum() 6、数据排序order by select * from Person3 where age>25 and age<=30 order by age ASC; --注:order by 子句要放在where 子句之后 7通配符过滤'_', '%' select * from Person3 where name like'_erry' --检索以任意字符开头,剩余部分为"erry"的数据 select * from Person3 where name like'%n%' --检索name中包含字符n的 8空值处理isnull/ is not null select * from Person3 where name is not null --is not null 判断name不为null的数据 9多值匹配 in select * from Person3 where age in(27,28,35) --age 为27或28或35的 10数据分组group by select age,avg(salary) from Person3 group by age --根据age进行分组 11Having子句 select age,count(*)as 人数from person3 group by age having count(*)>1 --having必须放在group by之后,having只能对分组后的数据进行过滤 |