ORMLITE ORDER_BY多列 [英] ORMLITE ORDER_BY with multiple columns

查看:181
本文介绍了ORMLITE ORDER_BY多列的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在最近的android项目中使用 ormlite .我想通过查询表中的多个列(例如两列)来进行排序.我该如何实现?

I am using ormlite in my recent android project. I want to order by on a query on multiple columns in a table (say two columns). How can I achieve that??

以下是单个订单的代码...

Here is the code for a single order by...

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(...).

All you need to do is to call orderBy(...) multiple times.

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

文档对此进行了介绍.引用:

This is covered by the documentation. To quote:

在SQL查询语句中添加"ORDER BY"子句,以按指定的列名对结果进行排序.使用升序布尔值获取升序或降序.可以多次调用以按多列分组.

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 :

在SQL查询语句中添加"ORDER BY"子句.可以多次调用此命令以添加其他"ORDER BY"子句.首先应用较早的版本.

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.

这篇关于ORMLITE ORDER_BY多列的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆