开发者

How to get the greatest of two columns values in MySQL?

I'm trying to do something like this:

SELECT MAX(
  ADDDATE(expirationdate, INTERVAL 1 YEAR),
  ADDDATE(now(), INTERVAL 1 YEAR)
)

开发者_如何学GoThat is, get "a year from now", or "a year from the expiration date stored in the table", whichever is greater (i'm renewing people's subscriptions).

This obviously doesn't work, since MAX() is for aggregation between rows, not for comparing 2 values. Is there a function that'll do this in MySQL? (i'd like to avoid doing an IF)


greatest()

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜