考虑以下示例查询:
SELECT foo.bar,
DATEDIFF(
# Some more advanced logic, such as IF(,,), which shouldn't be copy pasted
) as bazValue
FROM foo
WHERE bazValue >= CURDATE() # <-- This doesn't work
我怎样才能bazValue
在查询中稍后提供?我更喜欢这个,因为我相信如果可能的话,将代码维护在一个地方就足够了。