我对以下 SQL 查询 (MySQL) 有疑问:
SELECT CAST(LEFT(SUBSTR(STORE.VALUE, LOCATE('timestamp":', STORE.VALUE)+11),13) AS UNSIGNED) as starttime
FROM STORE
HAVING starttime <= MIN(starttime)+600000;
此查询返回 1 个值:1344543364317
这是列 starttime 的最小值。
以下手动完成计算的查询返回更多值。
SELECT CAST(LEFT(SUBSTR(STORE.VALUE, LOCATE('timestamp":', STORE.VALUE)+11),13) AS UNSIGNED) as starttime
FROM STORE
HAVING starttime <= 1344543964317;
为什么这个查询返回更多的值?
编辑
关于数据的更多解释:不幸的是,大多数数据都毫无用处。基本上该表只包含两列:Key、Value。关键在这里并不重要。该值包含如下内容:{"changeset":"Z:1>6b|5+6b$Welcome to Etherpad Lite!\n\nThis pad text is synchronized as you type, so that everyone viewing this page sees the same text. This allows you to collaborate seamlessly on documents!\n\nEtherpad Lite on Github: http://j.mp/ep-lite\n","meta":{"author":"","timestamp":1344543364317,"atext":{"text":"Welcome to Etherpad Lite!\n\nThis pad text is synchronized as you type, so that everyone viewing this page sees the same text. This allows you to collaborate seamlessly on documents!\n\nEtherpad Lite on Github: http://j.mp/ep-lite\n\n","attribs":"|6+6c"}}}
所以我基本上只是提取时间戳值并将其显示为一个名为 starttime 的虚拟列。starttime 列的前 10 个值是
1344543364317
1344543365939
1344543366439
1344543366454
1344543368794
1344553433259
1344553434054
1344553499779
1344553500871
1344553502104