我想创建一个内部联接三个表像这样的,例如:
i want to create an inner join on three tables like this one for example:
SELECT C.Description, D.ItemDescription
FROM OrderDetailStatement AS D
INNER JOIN OrderHeaderStatement AS H
ON H.OrderHeaderStatementRefID = D.OrderHeaderStatementRefID
INNER JOIN customers AS C
ON H.CustomerRefID = C.CustomerRefID
WHERE (D.MixedValue > 1000)
但我有点糊涂了,请你给我一个演练?
but i'm a little bit confused, could you please provide me a walkthrough?
在此先感谢
ORMLite 现在支持的简单加入
语句的。你可以做类似如下:
ORMLite now supports simple JOIN
statements. You can do something like the following:
// start the order header query
QueryBuilder<OrderHeader, Integer> orderHeaderQb = orderHeaderDao.queryBuilder();
QueryBuilder<Customer, Integer> customerQb = customerDao.queryBuilder();
// join with the order query
orderHeaderQb.join(customerQb);
// start the order statement query
QueryBuilder<OrderStatement, Integer> orderStatementQb =
orderStatementDao.queryBuilder();
orderStatementQb.where().gt("mixedvalue", 100);
// join with the order-header query
orderStatementQb.join(orderHeaderQb);
List<OrderStatement> orderStatementQb.query();
不过请注意,你只能得到实体利用这种机制的查询生成器。如果你想从不同的对象,你的两个描述字段,那么你将不得不仍然使用原始查询。
Notice, however, that you can only get entities from the query builder using this mechanism. If you want to get your two description fields from different objects then you would have to still use a raw-query.
没有为原始查询,包括 Dao.queryRaw()
方法,你可以用你自己的SQL。我怀疑你已经发现他们了。这里是文档的原始查询的。
There is support for "raw queries" including the Dao.queryRaw()
method where you can use your own SQL. I suspect you've found them already. Here are the docs for raw queries.
上一篇:关联特定文件扩展名,以我的Android应用程序我的、应用程序、文件扩展名、Andr
下一篇:Android的使用SimpleCursorAdapter设置颜色不只是字符串字符串、颜色、Android、SimpleCursorAdapter