几乎所谓的标题
我基本上想做一个简单的查询...
SELECT *
FROM sign_in_out
WHERE user_id = 6
AND time_signed < DATE('2014-10-23 16:11:54')
ORDER BY time_signed DESC LIMIT 1
...在指定日期之前获取最近的登录/退出活动,以确定相关用户是否在当天开始时登录或退出。上面的查询工作正常,但问题是我没有这样的日期,我有年,星期和星期六。
如何在MySQL中创建这些DATE?
由于
答案 0 :(得分:2)
SELECT *
FROM sign_in_out
WHERE user_id = 6
AND time_signed < MAKEDATE(year_col,(week_col*7+(weekday-1)))
ORDER BY time_signed DESC LIMIT 1
选中手动 MAKEDATE