我有一个请求:
SELECT
*,
CASE WHEN NOW() BETWEEN `from` AND `to` THEN "1" ELSE "0" END AS status,
FROM
`table`
WHERE
NOW() > `created_at`
我想将NOW()替换为我的$ date变量(UTC)。 我该如何更改我的请求?
P.S我的查询有点改变。
谢谢!
答案 0 :(得分:2)
如果我们谈论MySQL,我认为我们基于这种语法,这应该有效:
SELECT *
FROM `table`
WHERE $date > `created_at`
从另一个问题source.
修改修改强>
新查询:
SELECT *,
CASE
WHEN $date BETWEEN `from` AND `to` THEN "1"
ELSE "0"
END
AS status,
FROM `table`
WHERE
$date > `created_at`