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月前
|
关系型数据库 MySQL Linux
Packet for query is too large (4467936 > 4194304). You can change this value on the server by setting the max_allowed_packet' variable
【10月更文挑战第15天】解决Packet for query is too large (4467936 > 4194304). You can change this value on the server by setting the max_allowed_packet' variable
95 1
|
7月前
|
SQL 关系型数据库 MySQL
mysql:1153 Got a packet bigger than ‘max_allowed_packet’ bytes的解决方法
mysql:1153 Got a packet bigger than ‘max_allowed_packet’ bytes的解决方法
122 0
|
7月前
|
关系型数据库 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
243 0
|
存储 缓存 大数据
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
|
关系型数据库 MySQL 数据库
mysql下的max_allowed_packet参数设置
mysql下的max_allowed_packet参数设置
1102 0
|
7月前
|
SQL 关系型数据库 MySQL
[ERR] 2006 - MySQL server has gone away,Got a packet bigger than 'max_allowed_packet' bytes
[ERR] 2006 - MySQL server has gone away,Got a packet bigger than 'max_allowed_packet' bytes
55 0
|
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 ...
189 0
|
SQL 关系型数据库 MySQL
Packets larger than max_allowed_packet are not allowed(mysql数据查询提示:不允许超过允许的最大数据包)解决方案
Packets larger than max_allowed_packet are not allowed(mysql数据查询提示:不允许超过允许的最大数据包)解决方案
355 0
|
缓存 关系型数据库 MySQL
mysql数据库导入报错:Got a packet bigger than‘max_allowed_packet’bytes解决方案
mysql数据库导入报错:Got a packet bigger than‘max_allowed_packet’bytes解决方案
275 0
mysql数据库导入报错:Got a packet bigger than‘max_allowed_packet’bytes解决方案
|
关系型数据库 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 …
398 0