Queries with joins

24 views
Skip to first unread message

Josejulio Martínez

unread,
May 19, 2012, 1:18:55 PM5/19/12
to ormlit...@googlegroups.com
Hello, 
I would like to know if is possible to do the following in ormlite using the Where (what i don't want is using the raw query if possible).

SELECT invoice.* 
FROM invoice
JOIN invoice_client ON invoice.invoice_id = invoice_client.invoice_id
WHERE invoice_client.rfc= "XXX101010HY3";

What i want to do is perform certain filters on other tables(using join) but only retrieving the base object in this case the Invoice object.

jc

unread,
May 20, 2012, 12:06:15 AM5/20/12
to ORMLite Users
You should be able to use the Where.in(subquery) to get the result you
want although it doesn't technically do a join.

To do this create two QueryBuilder objects, one for the "invoice" and
another for "invoice_client". For the invoice_client, define your
where however you want and then use it as the argument of the where.in
in your "invoice" QueryBuilder.

Josejulio Martínez

unread,
May 21, 2012, 11:42:05 AM5/21/12
to ormlit...@googlegroups.com
Thank you, that works for me very well.
Reply all
Reply to author
Forward
0 new messages