请教SQL语句问题

来源:百度知道 编辑:UC知道 时间:2024/04/27 11:26:07
student表有id(整形,主键) name(字符型) birthday(时间型) state(整型)
1:teacher表与student表结构相同,将teacher表中state大于500的记录插入到student表;

2:更新student表中id介于5-15之间的记录,并时state字段值为600,birthday字段为2002年1月1日 12点12分12秒;

3:从student表统计出字段name不同的记录数量,并且只把重名记录数量大于3的取出来

1.insert into student (name, birthday, state) select name, birthday, state from teacher where state>500
(这里假设id是自增的主键)
2.update student set state=600, birthday='2002-01-01 12:12:12' where id between 5 and 15
3.select name, count(id) from student group by name having count(id)>3