执行错误如下所示:
### Error querying database. Cause: java.sql.SQLSyntaxErrorException: 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 'LIMIT 10' at line 31 ### The error may exist in file [C:\student\sources\lycp\lycp-server\target\classes\mapper\cpdjtz\ScZcBxzwCpdjTzCxMapper.xml] ### The error may involve defaultParameterMap ### The error occurred while setting parameters ### SQL: SELECT st.dbid, st.jbh, st.xgh_jbh, st.scrwd_id, st.cj_id, st.gzrq, st.pb_id, st.xgq_zl, st.xgq_jc, st.xgq_cpdj, st.xgh_zl, st.xgh_jc, st.xgh_cpdj, st.zljldw, st.xgsj, sb.bzmc, sbxx.bcmc, ry.xm, ry.gh FROM sc_zc_bxzw_cpdj_tz st LEFT JOIN sc_zc_ccp_cz szcc ON st.ccp_cz_id = szcc.dbid LEFT JOIN sc_scrwd ss ON st.scrwd_id = ss.dbid LEFT JOIN rl_yg ry ON st.czr_id = ry.dbid LEFT JOIN sc_zc_pb szp ON st.pb_id = szp.dbid LEFT JOIN sc_bz sb ON st.cj_id = sb.dbid LEFT JOIN sc_bz_sb sbs ON st.cj_gypb_id = sbs.dbid left join sc_bcxx sbxx on szp.bc_id = sbxx.dbid ORDER BY st.xgsj DESC; LIMIT ? ### Cause: java.sql.SQLSyntaxErrorException: 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 'LIMIT 10' at line 31 ; bad SQL grammar []; nested exception is java.sql.SQLSyntaxErrorException: 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 'LIMIT 10' at line 31 (第一次写博客,图片一直上传失败,不知道为啥,只能用文字了,谅解一下)
sql语句如下:
SELECT
st.dbid,
st.jbh,
st.xgh_jbh,
st.scrwd_id,
st.cj_id,
st.gzrq,
st.pb_id,
st.xgq_zl,
st.xgq_jc,
st.xgq_cpdj,
st.xgh_zl,
st.xgh_jc,
st.xgh_cpdj,
st.zljldw,
st.xgsj,
sb.bzmc,
sbxx.bcmc,
ry.xm,
ry.gh
FROM
sc_zc_bxzw_cpdj_tz st
LEFT JOIN sc_zc_ccp_cz szcc ON st.ccp_cz_id = szcc.dbid
LEFT JOIN sc_scrwd ss ON st.scrwd_id = ss.dbid
LEFT JOIN rl_yg ry ON st.czr_id = ry.dbid
LEFT JOIN sc_zc_pb szp ON st.pb_id = szp.dbid
LEFT JOIN sc_bz sb ON st.cj_id = sb.dbid
LEFT JOIN sc_bz_sb sbs ON st.cj_gypb_id = sbs.dbid
LEFT JOIN sc_bcxx sbxx on szp.bc_id = sbxx.dbid
ORDER BY st.xgsj DESC;
这个问题也是比较头疼,找了很久(关键是这个sql语句在navicat上能运行),最后发现因为我这个项目用到了分页的插件,所以执行的时候后面会自动给我加上分页的sql语句,然而我最后排序那里写了个分号,所以报错了。
解决如下: 将sql语句末尾的分号删除即可解决
最后成功运行,查询到了结果
原文链接:https://blog.csdn.net/Alomed/article/details/123760967
|
免责声明:
1,海欣资源网所发布的资源由网友上传和分享,不保证信息的正确性和完整性,且不对因信息的不正确或遗漏导致的任何损失或损害承担责任。
2,海欣资源网的资源来源于网友分享,仅限用于学习交流和测试研究目的,不得将上述内容用于商业或者非法用途,否则,一切后果请用户自负。
3,海欣资源网所发布的资源由网友上传和分享,版权争议与本站无关,您必须在下载后的24个小时之内,从您的电脑中彻底删除上述内容。
4,如果您喜欢,请支持正版,购买正版,得到更好的正版服务,如有侵权,请联系我们删除并予以真诚的道歉,联系方式邮箱 haixinst@qq.com
|