简体   繁体   English

根据其他列在HSQLDB中添加日期间隔

[英]Add Interval to date in HSQLDB based on other column

I'm using hsqldb as in-memory database for unittests, the production system is running with mysql. 我使用hsqldb作为单元测试的内存数据库,生产系统正在运行mysql。 The following query does work with mysql, but not if applied with hsqldb: 以下查询适用于mysql,但不适用于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. 当我使用固定值时,它确实适用于hsqldb,但这不是必需的行为。

The errormessage hsqldb returns: 错误消息hsqldb返回:

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

Multiply a constant interval with your column. 将恒定间隔乘以您的列。

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

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM