I am querying a MySQL database and I need to add a year to a column (of type date) before the compare operation.
我正在查询一个MySQL数据库,需要在执行比较操作之前向列(类型为date)添加一年。
I would expect is to look something like this:
我想大概是这样的:
SELECT count(*) AS count
FROM users
WHERE renewed + 1 year < '2009-12-12'
2 个解决方案
#1
3
Use:
使用:
SELECT COUNT(*) AS count
FROM USERS u
WHERE DATE_ADD(u.renewed, INTERVAL 1 YEAR) < '2009-12-12'
Reference:
参考:
- DATE_ADD
- DATE_ADD
#2
#1
3
Use:
使用:
SELECT COUNT(*) AS count
FROM USERS u
WHERE DATE_ADD(u.renewed, INTERVAL 1 YEAR) < '2009-12-12'
Reference:
参考:
- DATE_ADD
- DATE_ADD