- 数据库操作语言DML(DATABASE Manipulation LANGUAGE)
-
Insert Insert into 表名 (id,name,birthday) va7ues (1,’wyx’,’2003-07-01 09:15:23’); Select Select * from weiyuxuan where id<>3; Select countryside,count(id) from world.city group by countryside; select count(id),name,length from c where name like '%c%'group by length; Select district,count(id) from world.city where countrycode=’chn’ group by district; select max(s_birth),s_sex from student group by s_sex;按照性别取年龄最小 select * from student where s_sex='女' and s_birth = '1992-03-01';取女性生日在’1992-03-01’的人、 select * from student where s_sex='女' and s_birth = (select max(s_birth) from student where s_sex='女');女性年龄最小 select * from student where s_sex='男'and s_birth=(select max(s_birth) from student where s_sex='女');男性中与女性年龄最小同岁 select count(s_id),year(s_birth) from student group by year(s_birth);求生日在各年的有几个 select count(s_id),year(s_birth) from student group by year(s_birth) having count(s_id)>3;结果之后再查询用having select * from course c left join score s on c.c_id=s.c_id;关联语句 select s_score,s.c_id,c_name from course c left join score s on s.c_id=c.c_id where s.c_id is null or s_id is null;课程有但没成绩left join 以左边为准right join 以右边为准 --多表关联 找各表关联列 select * from student s left join score f on s.s_id=f.s_id left join course c on c.c_id=f.c_id left join teacher t on t.t_id=c.t_id; > select * from student s left join score f on s.s_id=f.s_id left join course c on c.c_id=f.c_id left join teacher t on t.t_id=c.t_id where c_name='语文';