如何通过MySql DB上的Spring Jdbc模板在获取列表中应用限制和偏移量

问题描述 投票:0回答:1

需要在MySql DB上使用jdbc模板对选择查询应用限制和偏移量。

String query = "SELECT *from loaquesform F inner join loainfo N inner join loa_approval A on F.loaId = N.loaId and N.loaId = A.loaId where loaStatus IN (?) LIMIT ?, ? order by loaId desc;"

LoaFormList = userJdbcTemplateMysql.query(query,
                            new BeanPropertyRowMapper(LoaFormWithSrv.class),
                            new Object[]{loaStatusCriteria.getLoaStatus(),loaStatusCriteria.getLimit(), 
                                loaStatusCriteria.getOffset()});

我用限制和偏移= 10调用此程序

我收到以下错误 -

> You have an error in your SQL syntax; check the manual that
> corresponds to your MySQL server version for the right syntax to use
> near ''10', '10' order by loaId desc' at line 1
java mysql spring jdbctemplate
1个回答
0
投票

ORDER BY条款的needs to be preceded LIMIT

String query = 
   "SELECT * from loaquesform F inner join loainfo N inner join loa_approval A on F.loaId = N.loaId and N.loaId = A.loaId where loaStatus IN (?) order by loaId desc LIMIT ?, ?;"
© www.soinside.com 2019 - 2024. All rights reserved.