根据其他列在HSQLDB中添加日期间隔 [英] Add Interval to date in HSQLDB based on other column

查看:99
本文介绍了根据其他列在HSQLDB中添加日期间隔的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用hsqldb作为单元测试的内存数据库,生产系统正在运行mysql.以下查询确实适用于mysql,但不适用于hsqldb:

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();

我想检索所有特定行,其中间隔基于另一列.当我使用固定值时,它确实适用于hsqldb,但这不是必需的行为.

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:

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();

这篇关于根据其他列在HSQLDB中添加日期间隔的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆