这是为什么
SELECT strftime('%s', timestamp,'localtime') from locationLog WHERE strftime('%s', timestamp,'localtime') > 999999999999999999 ORDER BY _id DESC
当我的所有行的“时间戳”值都较低时返回任何输出
在我的例子中,上面的查询返回
1334735588
1334735349
1334734317
1334734178
1334734172
and so on...
它返回我的整个表格。
如果我切换>
至<
它什么也不返回。
我想我正在尝试比较不同类型的变量或类似的东西。
最佳答案
您正在将text
值与integer
值进行比较,因此sqlite将integer
值转换为text
,并进行字符串比较:
sqlite> select strftime('%s', '2002-02-02', 'localtime');
1012611600
sqlite> select typeof(strftime('%s', '2002-02-02', 'localtime'));
text
sqlite> select typeof(999999999999999999);
integer
sqlite> select strftime('%s', '2002-02-02', 'localtime') > 999999999999999999;
1
sqlite> select cast(strftime('%s', '2002-02-02', 'localtime') as integer) > 999999999999999999;
0
如上所示,解决方案是将strftime
的返回值转换为某种数字类型。
关于php - 选择比我的变量大的纪元时间戳,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10381842/