mysql 从数据库中筛选出 符合 (当前时间-数据库中date)>24个月
数据库中含有多条记录
这是我自己做的 select * from table where(select PERIOD_DIFF(date_format(now(),'%Y%m'),date_format(ANY(select period from test.cardaccount c),'%Y%m')))>24;
这样会提示 “Subquery returns more than 1 row”
谢谢 在线等
数据库中含有多条记录
这是我自己做的 select * from table where(select PERIOD_DIFF(date_format(now(),'%Y%m'),date_format(ANY(select period from test.cardaccount c),'%Y%m')))>24;
这样会提示 “Subquery returns more than 1 row”
谢谢 在线等
select * from tableName where date_add(period,interval 24 month) < now();
(当前时间-数据库中date)>24个月 ,也就是数据库中日期加上24个月,仍然小于当前日期。楼主是不是想的复杂了些。