今天写一个查询功能的时候,出现了一个错误,当我写好后端接口,准备去前端掉用的时候出现了如下错误:
###::YouhaveanerrorinyourSQLsyntax;checkthemanualthatcorrespondstoyourMySQLserverversionfortherightsyntaxtousenear’LIMIT10’atline31###Theerrormayexistinfile[C:studentsourceslycplycp-server ]###TheerrormayinvolvedefaultParameterMap###Theerroroccurredwhilesettingparameters###SQL:,,st.xgh_jbh,st.scrwd_id,st.cj_id,,st.pb_id,st.xgq_zl,st.xgq_jc,st.xgq_cpdj,st.xgh_zl,st.xgh_jc,st.xgh_cpdj,,,,,,ry.ghFROMsc_zc_bxzw_cpdj_tzstLEFTJOINsc_zc_ccp_czszccONst.ccp_cz_id=szcc.dbidLEFTJOINsc_scrwdssONst.scrwd_id=ss.dbidLEFTJOINrl_ygryONst.czr_id=ry.dbidLEFTJOINsc_zc_pbszpONst.pb_id=szp.dbidLEFTJOINsc_bzsbONst.cj_id=sb.dbidLEFTJOINsc_bz_sbsbsONst.cj_gypb_id=sbs.dbidleftjoinsc_bcxxsbxxonszp.bc_id=;LIMIT###Cause::YouhaveanerrorinyourSQLsyntax;checkthemanualthatcorrespondstoyourMySQLserverversionfortherightsyntaxtousenear’LIMIT10’atline31;badSQLgrammar[];:YouhaveanerrorinyourSQLsyntax;checkthemanualthatcorrespondstoyourMySQLserverversionfortherightsyntaxtousenear’LIMIT10’atline31 (第一次写博客,图片一直上传失败,不知道为啥,只能用文字了,谅解一下)
sql语句如下:
SELECT
,
,
st.xgh_jbh,
st.scrwd_id,
st.cj_id,
,
st.pb_id,
st.xgq_zl,
st.xgq_jc,
st.xgq_cpdj,
st.xgh_zl,
st.xgh_jc,
st.xgh_cpdj,
,
,
,
,
,
FROM
sc_zc_bxzw_cpdj_tz st
LEFT JOIN sc_zc_ccp_cz szcc ON st.ccp_cz_id =
LEFT JOIN sc_scrwd ss ON st.scrwd_id =
LEFT JOIN rl_yg ry ON st.czr_id =
LEFT JOIN sc_zc_pb szp ON st.pb_id =
LEFT JOIN sc_bz sb ON st.cj_id =
LEFT JOIN sc_bz_sb sbs ON st.cj_gypb_id =
LEFT JOIN sc_bcxx sbxx on szp.bc_id =
ORDER BY DESC;
这个问题也是比较头疼,找了很久(关键是这个sql语句在navicat上能运行),最后发现因为我这个项目用到了分页的插件,所以执行的时候后面会自动给我加上分页的sql语句,然而我最后排序那里写了个分号,所以报错了。
解决如下: 将sql语句末尾的分号删除即可解决
最后成功运行,查询到了结果