gpt4 book ai didi

android - 具有多列的 ORMLITE ORDER_BY

转载 作者:IT老高 更新时间:2023-10-28 23:40:39 26 4
gpt4 key购买 nike

我在最近的 android 项目中使用 ormlite。我想对表中的多个列(比如两列)的查询进行排序。我怎样才能做到这一点?

这是一个订单的代码...

QueryBuilder<Visit, Integer> qb = getHelper().getVisitDao().queryBuilder();
qb.where().eq("FOREIGN_ID", id);
qb.orderBy("VISIT_DATE", false);

最佳答案

I want to order by on a query on multiple columns in a table(say two columns). How can i achieve that??

您需要做的就是多次调用 orderBy(...)

qb.orderBy("VISIT_DATE", false);
qb.orderBy("order-column", false);
...

这由 documentation 覆盖。 .引用:

Add "ORDER BY" clause to the SQL query statement to order the results by the specified column name. Use the ascending boolean to get a ascending or descending order. This can be called multiple times to group by multiple columns.

还有 javadocs :

Add "ORDER BY" clause to the SQL query statement. This can be called multiple times to add additional "ORDER BY" clauses. Ones earlier are applied first.

关于android - 具有多列的 ORMLITE ORDER_BY,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/15666847/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com