Tag Archives: Example.SetOrderByClause

Tkmybatis uses Example.SetOrderByClause Use for sorting and multiple sort fields

How to use it when sorting individual fields

example.setOrderByClause("user_type ASC"); //Output sorted by user type in ascending order

Running SQL looks something like this

SELECT ...
FROM tab_sy_user
order by user_type ASC 

The method of using when sorting multiple fields separated by a comma

The query results are sorted by the order in which the fields are sorted, and if the conditions are the same, continue the conditional sort by the next field until the last field sort is complete.

 //First according to user_type ascending ASC sorting, if there is the same condition, in accordance with the level condition descending DESC sorting
example.setOrderByClause("user_type ASC, level DESC");

Running SQL looks something like this

SELECT ...
FROM tab_sy_user
order by user_type ASC, level DESC