postgre分页查询报错:ERROR: LIMIT #,# syntax is not supported 建议:Use separate LIMIT and OFFSET clauses

简介: postgre分页查询报错:ERROR: LIMIT #,# syntax is not supported 建议:Use separate LIMIT and OFFSET clauses

问题


使用postgre查询时报错:


ERROR: LIMIT #,# syntax is not supported 建议:Use separate LIMIT and OFFSET clauses

cd93755570c44d8db0ab731138f4f74b.png

分析


错误类型看时PSQLException,说明是postgresql数据库识别的错误

可以看出是因为 sql语句中的"LIMIT #,#"无法识别!

这明显是mysql分页查询语法

select * from table limit #{pageSize}, #{size}
select * from table limit 1, 10

第一次使用postgresql数据库,并不清楚它的sql语句规范


解法


select * from table LIMIT 1 OFFSET 10
//注意该语句的意思是从第10条开始,只查一条数据,这里区分mysql
select * from table LIMIT 10 OFFSET 0
//这个才是从0开始查10条数据
目录
相关文章
|
2月前
|
SQL 关系型数据库 MySQL
mysql:1153 Got a packet bigger than ‘max_allowed_packet’ bytes的解决方法
mysql:1153 Got a packet bigger than ‘max_allowed_packet’ bytes的解决方法
27 0
|
2月前
|
Java 数据库连接 mybatis
项目移植到原先mybasis项目里出现BindingException: Invalid bound statement (not found): **selectPage
项目移植到原先mybasis项目里出现BindingException: Invalid bound statement (not found): **selectPage
20 1
|
2月前
|
关系型数据库 MySQL
Packet for query is too large (4,544,730 > 4,194,304). You can change this value on the server by se
Packet for query is too large (4,544,730 > 4,194,304). You can change this value on the server by se
|
存储 缓存 大数据
Starrocks执行查询报错:Memory of process exceed limit. Used: XXX, Limit: XXX. Mem usage has exceed the limit of BE
Starrocks执行查询报错:Memory of process exceed limit. Used: XXX, Limit: XXX. Mem usage has exceed the limit of BE
|
SQL 存储 安全
PageHelper不安全的分页问题,导致ParserException: syntax error, error in :'it 1 LIMIT ? ', expect LIMIT, actual ...
PageHelper不安全的分页问题,导致ParserException: syntax error, error in :'it 1 LIMIT ? ', expect LIMIT, actual ...
148 0
|
SQL 关系型数据库 MySQL
Packets larger than max_allowed_packet are not allowed(mysql数据查询提示:不允许超过允许的最大数据包)解决方案
Packets larger than max_allowed_packet are not allowed(mysql数据查询提示:不允许超过允许的最大数据包)解决方案
270 0
|
SQL Java 程序员
记录:1221 - Incorrect usage of UNION and ORDER BY...【亲测有效】
记录:1221 - Incorrect usage of UNION and ORDER BY...【亲测有效】
385 0
|
前端开发 Java 关系型数据库
记录:The field files exceeds its maximum permitted size of 1048576 bytes...【亲测有效】
记录:The field files exceeds its maximum permitted size of 1048576 bytes...【亲测有效】
1082 0
|
SQL 关系型数据库 MySQL
MySQL Case-max_allowed_packet过小是否会截取sql文本?
max_allowed_packet是否会截取sql文本呢
120 1
MySQL Case-max_allowed_packet过小是否会截取sql文本?
|
关系型数据库 MySQL
MySQL - Packet for query is too large (4,544,730 > 4,194,304). You can change this value on the …
MySQL - Packet for query is too large (4,544,730 > 4,194,304). You can change this value on the …
324 0