Add Interval to date in HSQLDB based on other column

痞子三分冷 提交于 2019-12-12 06:16:50

问题


I'm using hsqldb as in-memory database for unittests, the production system is running with mysql. The following query does work with mysql, but not if applied with hsqldb:

select * from table where columnTimestamp + INTERVAL 'columnDays' DAY < now();

I want to retrieve all specific rows where the interval is based on another column. When I use fixed values it does work with hsqldb, but this is not the required behaviour.

The errormessage hsqldb returns:

data exception: invalid interval format / Error Code: -3406 / State: 22006

回答1:


Multiply a constant interval with your column.

select * 
from table 
where columnTimestamp + (INTERVAL '1' DAY * columndays) < now();


来源:https://stackoverflow.com/questions/34650406/add-interval-to-date-in-hsqldb-based-on-other-column

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!