因此,我尝试按以下方式使用Between
时间戳,我将日期存储为Unix时间戳,并且我第一次尝试将其转换,然后在所述时间之间获取所有用户。
SELECT
users.*,
DATE_FORMAT(
FROM_UNIXTIME(users.created),
'%Y %b %e '
) AS date_formatted
FROM
node
LEFT JOIN users
ON node.uid = users.uid
WHERE node.uid != 0
AND
(date_formatted BETWEEN '2017-06-30 00:00:00' AND '2018-06-30 00:00:00')
GROUP BY uid
但是我收到此错误
“ where子句”中的未知列“ date_formatted”
答案 0 :(得分:1)
users.created BETWEEN '2017-06-30 00:00:00' AND '2018-06-30 00:00:00'
但是,如果您不想冒险,可以在WHERE语句中应用格式/广播。