项目场景:

jeecg表单,条件查询


问题描述:

查询条件筛选后,无相应的查询结果。


原因分析:

查看services提示:

You have an error in your SQL syntax; check the manual that corresponds to y...

解决方案:

提示写的很清楚,查询语句sql出错。打断点,在java代码中获取到sql语句,发现昨天新增的

order by t.time

排序条件,写在了

limit 0,10

后面,导致sql语句出错。

  • 错误sql:
SELECT
	a.id,
	a.time,
	a.title
FROM
	message a,
WHERE
  a.delete = 0 
	AND a.userName = '张三' 
	LIMIT 0,10 
	ORDER BY
	a.time DESC
  • 正确sql:
SELECT
	a.id,
	a.time,
	a.title
FROM
	message a,
WHERE
  a.delete = 0 
	AND a.userName = '张三' 
	ORDER BY 
	a.time DESC
	LIMIT 0,10 

ps:

mysql中的sql语句:

select * from 表名 limit 0,10;
表示取表中的前10条数据(从第1条开始,取10条)