我在Moodle中遇到这个MySQL查询的问题。它返回1月和2月的记录,它应该只返回1月份的记录。
SELECT c.shortname AS Course, g.name AS Project, u.username AS Student,
FROM_UNIXTIME(u.firstaccess, '%d-%m-%Y') AS Logindate
FROM prefix_course AS c
JOIN prefix_groups AS g ON g.courseid = c.id
JOIN prefix_groups_members AS m ON g.id = m.groupid
JOIN prefix_user AS u ON m.userid = u.id
WHERE c.id = 8 AND DATE_FORMAT(FROM_UNIXTIME(u.firstaccess), '%d-%m-%Y') BETWEEN '15-01-2016' AND '31-01-2016'
当我将日期更改为例如'01 -02-2016'和'15 -02-2016'它从2月返回正确的记录。我尝试了几件事,但我不能仅从2016年1月过滤掉这些记录。
有人提出建议吗?