发布于个人的CSDN :Mapper在order by中使用$的情况
MyBatis项目种,在测试接口是发现,返回的json数据不能按照传入的参数"sortBy": "id"进行order by id排序,当时返回的json数据如下图:

发现该问题时,我最先是将sortBy": "id"改为sortBy": "sales_history.id"。
但是,没有用!

第二次将sortBy": "sales_history.id"改为sortBy": "",再测试

这次出现了如期的升序结果。
这是为什么呢?
回去检查一下这句order by #{sort},现在我改成了order by ${sort},再试试看

结果也是可以的。
经查证:
order by 中就需要使用 $[MyBatis]Mapper在order by中使用$的情况
原文:https://www.cnblogs.com/melodyjerry/p/14457197.html