SELECT id, created_at FROM "location_reviews" ORDER BY created_at DESC;
PostgreSQL的顺序通过,并限制不返回预期的行
id | created_at
-----+---------------------
251 | 2015-12-20 00:00:00
426 | 2015-12-20 00:00:00
357 | 2015-12-20 00:00:00
SELECT id, created_at FROM "location_reviews" ORDER BY created_at DESC LIMIT 1;
id | created_at
-----+---------------------
251 | 2015-12-20 00:00:00
SELECT id, created_at FROM "location_reviews" ORDER BY created_at DESC LIMIT 1 OFFSET 1;
id | created_at
-----+---------------------
251 | 2015-12-20 00:00:00
SELECT id, created_at FROM "location_reviews" ORDER BY created_at DESC LIMIT 1 OFFSET 2;
id | created_at
-----+---------------------
357 | 2015-12-20 00:00:00
为什么我的OFFSET 1
查询返回第二个条目(id = 426)?相反,它返回的查询没有OFFSET
。 created_at
列的类型为timestamp without time zone
。