Postgresql 如何在postgressql查询中添加LIMIT子句?
我想在postgressql查询中添加LIMIT子句,但它给出了一个错误Postgresql 如何在postgressql查询中添加LIMIT子句?,postgresql,Postgresql,我想在postgressql查询中添加LIMIT子句,但它给出了一个错误 SELECT complaint_id FROM complaint_details_v2 a where a.road_dept SIMILAR TO 'PWDBnR' order by a.server_time desc LIMIT 0, 10 以下是错误: ERROR: LIMIT #,# syntax is not supported SQL state: 42601 Hint: Use separate LI
SELECT complaint_id FROM complaint_details_v2 a where a.road_dept SIMILAR TO 'PWDBnR' order by a.server_time desc LIMIT 0, 10
以下是错误:
ERROR: LIMIT #,# syntax is not supported
SQL state: 42601
Hint: Use separate LIMIT and OFFSET clauses.
Character: 87
对于上面的示例-跳过“0”位
SELECT complaint_id FROM complaint_details_v2 a where a.road_dept SIMILAR TO
'PWDBnR' order by a.server_time desc LIMIT 10
限制0,10不是postgres方言,请使用偏移量。例如,如果您想查看下10个结果:
SELECT complaint_id FROM complaint_details_v2 a where a.road_dept SIMILAR TO
'PWDBnR' order by a.server_time desc OFFSET 10 LIMIT 10
查询应用于选择前10行
SELECT complaint_id FROM complaint_details_v2 a where a.road_dept SIMILAR TO 'PWDBnR' order by a.server_time desc LIMIT 10
如果要在y记录之后选择x行(从0开始计数),则应使用
SELECT complaint_id FROM complaint_details_v2 a where a.road_dept SIMILAR TO 'PWDBnR' order by a.server_time desc LIMIT x OFFSET y
希望这有帮助