SELECT `Item`.`name`, DATE_SUB(Item.modified, INTERVAL 1 DAY),
CASE
WHEN DATE_SUB(Item.modified, INTERVAL 1 DAY) > Item.modified
THEN 'FALSE'
ELSE 'TRUE'
END status, `Item`.`restaurant_id` FROM `fs_development`.`items` AS `Item`
WHERE `Item`.`restaurant_id` = (677)
ORDER BY `modified` DESC LIMIT 1
我希望状态字段为“TRUE”或“FALSE”,以指示记录是否在当天更新。
到目前为止,上述情况尚未奏效。
答案 0 :(得分:0)
SELECT `Item`.`name`,
DATE_SUB(Item.modified, INTERVAL 1 DAY),
CASE WHEN date(Item.modified) = curdate()
THEN 'TRUE'
ELSE 'FALSE'
END status,
`Item`.`restaurant_id`
FROM `fs_development`.`items` AS `Item`
WHERE `Item`.`restaurant_id` = (677)
ORDER BY `modified` DESC
LIMIT 1