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条数据
目录
相关文章
|
4月前
|
关系型数据库 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
161 1
|
9月前
|
SQL 关系型数据库 MySQL
mysql:1153 Got a packet bigger than ‘max_allowed_packet’ bytes的解决方法
mysql:1153 Got a packet bigger than ‘max_allowed_packet’ bytes的解决方法
158 0
|
9月前
|
关系型数据库 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
273 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参数设置
1166 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 ...
209 0
|
Oracle 关系型数据库 数据库
Oracle 报错:exceeded simultaneous SESSIONS_PER_USER limit
Oracle 报错:exceeded simultaneous SESSIONS_PER_USER limit
Oracle 报错:exceeded simultaneous SESSIONS_PER_USER limit
|
缓存 数据可视化
'dict' object has no attribute '_txn_read_preference' && Sort exceeded memory limit of 10485760
'dict' object has no attribute '_txn_read_preference' && Sort exceeded memory limit of 10485760
224 0
|
前端开发 Java 关系型数据库
记录:The field files exceeds its maximum permitted size of 1048576 bytes...【亲测有效】
记录:The field files exceeds its maximum permitted size of 1048576 bytes...【亲测有效】
1159 0
|
缓存 关系型数据库 MySQL
mysql数据库导入报错:Got a packet bigger than‘max_allowed_packet’bytes解决方案
mysql数据库导入报错:Got a packet bigger than‘max_allowed_packet’bytes解决方案
336 0
mysql数据库导入报错:Got a packet bigger than‘max_allowed_packet’bytes解决方案