题解 | #插入记录(二)#
插入记录(二)
https://www.nowcoder.com/practice/9681abf28745468c8adacb3b029a18ce
insert into exam_record_before_2021(uid, exam_id, start_time, submit_time, score) select uid, exam_id, start_time, submit_time, score from exam_record where YEAR(submit_time) < '2021' 1.如果需要避开某些字段,最好采用指定字段插入。比如这题中要避开id字段,否则新表的id就不连续了 2.判断是否为null是 is/is not,而不是 != 3.datetime数据的比较,可以用内置函数YEAR()来过滤时间范围