我们在写SQL时候,往往会需要格式化或多表联合查询,现在来一个实例看看这个问题
SELECT t.id, t.topic_title AS title,
IF(sch.is_true='1','答案正确','答案错误') as answer,
DATE_FORMAT(sch.create_time, '%Y-%m-%d %H:%i:%s') as createtime
FROM topic t
LEFT JOIN student_commit_history sch
on t.id = sch.topic_id
where sch.student_id =41 AND sch.create_time
BETWEEN '2020-03-01 00:00:00' and '2020-03-12 00:00:00'