'where a - b > 0' 与 'where a > b' 不一样吗

c__sys 2012-04-10 02:34:34
在sqlite里,我的如下第二个查询失败了。不知道啥原因。

就是说这样写,可以:where endtime + duration - strftime('%s', CURRENT_TIMESTAMP) > 0

这样失败了:where endtime + duration > strftime('%s', CURRENT_TIMESTAMP)

====

sqlite> select planid, endtime, duration from plan where endtime + duration - strftime('%s', CURRENT_TIMESTAMP) > 0;
5|1334029971|486400
6|1335029971|586400
7|1336029971|686400
8|1337029971|786400
9|1338029971|886400
10|1339029971|986400
sqlite> select planid, endtime, duration from plan where endtime + duration > strftime('%s', CURRENT_TIMESTAMP);
sqlite>
sqlite> .exit
...全文
104 3 打赏 收藏 转发到动态 举报
写回复
用AI写文章
3 条回复
切换为时间正序
请发表友善的回复…
发表回复
c__sys 2012-04-10
  • 打赏
  • 举报
回复
thank you

sample data attached

$ cat plan.sql

DROP TABLE plan;
CREATE TABLE plan
(
PlanId integer PRIMARY KEY,
TaskId integer DEFAULT 0,
Cameraid varchar(64) DEFAULT '',
MediaCompressType integer DEFAULT 0,
MediaResolutionType integer DEFAULT 0,
Url varchar(256) DEFAULT '',
PlanType integer DEFAULT 0,
starttime integer DEFAULT 0,
endtime integer DEFAULT 0,
Duration integer DEFAULT 0,
AlarmSource varchar(256) DEFAULT '',
AlarmType varchar(256) DEFAULT '',
AlarmParm varchar(256) DEFAULT '',
Response integer DEFAULT 0
);

INSERT INTO plan VALUES ( 1, 0, "camera1", 0, 0, "url1", 60, 0, 1330029971, 86400, "alarm_source", "alarm_type", "alarm_param", 0 );
INSERT INTO plan VALUES ( 2, 0, "camera1", 0, 0, "url2", 60, 0, 1331029971, 186400, "alarm_source", "alarm_type", "alarm_param", 0 );
INSERT INTO plan VALUES ( 3, 0, "camera1", 0, 0, "url3", 60, 0, 1332029971, 286400, "alarm_source", "alarm_type", "alarm_param", 0 );
INSERT INTO plan VALUES ( 4, 0, "camera1", 0, 0, "url4", 60, 0, 1333029971, 386400, "alarm_source", "alarm_type", "alarm_param", 0 );
INSERT INTO plan VALUES ( 5, 0, "camera1", 0, 0, "url5", 60, 0, 1334029971, 486400, "alarm_source", "alarm_type", "alarm_param", 0 );
INSERT INTO plan VALUES ( 6, 0, "camera1", 0, 0, "url6", 60, 0, 1335029971, 586400, "alarm_source", "alarm_type", "alarm_param", 0 );
INSERT INTO plan VALUES ( 7, 0, "camera1", 0, 0, "url7", 60, 0, 1336029971, 686400, "alarm_source", "alarm_type", "alarm_param", 0 );
INSERT INTO plan VALUES ( 8, 0, "camera1", 0, 0, "url8", 60, 0, 1337029971, 786400, "alarm_source", "alarm_type", "alarm_param", 0 );
INSERT INTO plan VALUES ( 9, 0, "camera1", 0, 0, "url9", 60, 0, 1338029971, 886400, "alarm_source", "alarm_type", "alarm_param", 0 );
INSERT INTO plan VALUES ( 10, 0, "camera1", 0, 0, "url10", 60, 0, 1339029971, 986400, "alarm_source", "alarm_type", "alarm_param", 0 );

$

$ sqlite3 plan.db
sqlite> .read plan.sql
sqlite> .exit
$
ACMAIN_CHM 2012-04-10
  • 打赏
  • 举报
回复
建议提供一些例子,这样方便测试。估计是数据类型转换的原因。
rucypli 2012-04-10
  • 打赏
  • 举报
回复
不懂 应该是隐式转换的问题

2,209

社区成员

发帖
与我相关
我的任务
社区描述
其他数据库开发 其他数据库
社区管理员
  • 其他数据库社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧