Openshift对MySQL的INTERVAL没有反应 [英] Openshift does not react on INTERVAL of MySQL

查看:90
本文介绍了Openshift对MySQL的INTERVAL没有反应的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经在locanhost和Openshift上测试了表test,但我遇到的问题是,在openshift上查询类似WHERE arrivaltime BETWEEN curtime() - INTERVAL 2 MINUTE AND curtime() + INTERVAL 2 MINUTE的数据时我什么也没回来,尽管在本地主机上我得到的是9号路由背部.在openshift上,我根据服务器时间插入到达时间.在localhost上,我正在根据本地时间插入到达时间,但是当我将查询更改为这种形式WHERE time_format(arrivaltime,'%H:%i')= time_format(curtime() ,'%H:%i')时,我在openshift上返回了9,但是我的响应必须是+- 2分钟.我该如何解决?还是有人拥有openshift帐户?如何测试下面的表格和查询?

I have tested the table test on the locanhost and Openshift and I am facing problem that on openshift I am not getting anything back when I query the data like this WHERE arrivaltime BETWEEN curtime() - INTERVAL 2 MINUTE AND curtime() + INTERVAL 2 MINUTE although on the localhost I am getting the route 9 back. On openshift I am insert arrivaltime according to the server time. On localhost I am inserting arrivaltime according to my local time but when I change the query to this form WHERE time_format(arrivaltime,'%H:%i')= time_format(curtime() ,'%H:%i') I am getting 9back on openshift but I need my response to be+- 2 minutes. How can I fix it? or does someone have a openshift account how can test the table and the query below?

感谢您的帮助.

测试表

CREATE TABLE test(
id INT(11) NOT NULL AUTO_INCREMENT PRIMARY KEY,
 arrivaltime Time  NOT NULL,
 route INT(11) NOT NULL   
)

插入数据:

INSERT INTO test(arrivaltime, route) values('04:16:00', 9)

此查询不适用于Openshift,而适用于localhost:

SELECT route FROM test
WHERE arrivaltime BETWEEN curtime() - INTERVAL 2 MINUTE AND curtime() + INTERVAL 2 MINUTE

openshift curtime()

04:15:15

当我在openshift上查询这样的测试时,我得到了响应,但是到达时间应该等于当前时间.

when I query the test like this on openshift I am getting response but the arrivaltime should be equal to the current time.

SELECT route FROM test
WHERE time_format(arrivaltime,'%H:%i')= time_format(curtime() ,'%H:%i')

推荐答案

好吧,我不太擅长MySQL.因此,也许有人可以在这里改善我的问题.但是我想问题出在您的服务器本地时间格式上,或者可能是在您添加或减去时间后MySQL如何返回时间格式.

well, I'm not really good at MySQL. So, maybe someone could improve my question here. But I guess the problem lies in your server local time format or maybe how the MySQL return the time format after you add or subtract the time.

对于这个问题,我建议您使用此查询,而不要尝试像这样直接修改它.

For this problem, I'll advise to use this query instead of trying to modify it directly like that.

select route from test where arrivaltime between subtime(curtime(), '00:02:00') and addtime(curtime(), '00:02:00');

还要确定问题出在哪里,也许您可​​以尝试使用此查询来检查是否存在警告或错误.

and also to make sure what the problem is, maybe you could try to check whether there is a warning or error by using this query.

show warnings;
show errors;

这篇关于Openshift对MySQL的INTERVAL没有反应的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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