Problem Description
In the MyBatis project, it is found in the test interface that the returned json data cannot "sortBy": "id"
be order by id
sorted according to the parameters passed in . The json data returned at the time is as follows:
solve
When I found the problem, I first sortBy": "id"
changed it to sortBy": "sales_history.id"
.
But it's no use!
For the second time, it will be sortBy": "sales_history.id"
changed to sortBy": ""
, retest.
This time, the ascending results appeared as expected .
Why is this?
Go back and check this sentence order by #{sort}
, now I changed it order by ${sort}
, and try again. The
result is okay .
summary
After verification:
- MyBatis Mapper
order by
needs to be used if used in$
For details, see the difference between $ and # in [MyBatis]Mapper