描述
现有一张试卷作答记录表exam_record,其中包含多年来的用户作答试卷记录,结构如下表:
作答记录表exam_record:
start_time是试卷开始时间
submit_time 是交卷,即结束时间
请删除exam_record表中作答时间小于5分钟整且分数不及格(及格线为60分)的记录;
后台会通过 SELECT * FROM exam_record; 语句来对比结果。
#方式一
delete from exam_record
where timediff(submit_time,start_time) < '00:05:00' and score < 60;
#方式二
delete from exam_record
where timestampdiff(minute,start_time,submit_time) < 5 and score < 60;
#方式三
delete from exam_record
where DATE_SUB(submit_time ,INTERVAL 5 MINUTE) < start_time and score < 60;
#方式四
delete from exam_record
where UNIX_TIMESTAMP(submit_time)-UNIX_TIMESTAMP(start_time) < 300 and score < 60;