我读了许多主题来获取在不同时期发布的数据,但由于我的mysql表中的时间是STRING格式,我无法实现。
SELECT s.user_id, count(*) AS wins, u.username, u.avatar,u.avatar_uploaded
FROM on_scores AS s
LEFT JOIN on_users AS u ON (u.userid = s.user_id)
WHERE s.is_high = '1' AND DATE(s.date_score) >= DATE_SUB(CURDATE(), INTERVAL 7 DAY)
GROUP BY s.user_id
ORDER BY wins DESC
LIMIT 10
我尝试了STR_TO_DATE
方法,但仍然没有输出。