问题
I would like to join three tables using QueryBuilder.join
and QueryBuilder.joinor
but I want parenthesis in the where clause something like this:
WHERE first_table_where AND (second_table_where OR third_table_where)
but it seems that is not possible.
Perhaps I am missing something. Any help would be appreciated.
回答1:
I guess that is a part of the doc you have been looking for...
If you want to do complex queries linearly, you can even use Reverse Polish Notation (of all things). There is a
Where.or(int)
andWhere.and(int)
methods which do the operation on the previous number of specified clauses.where.eq(Account.NAME_FIELD_NAME, "foo"); where.eq(Account.PASSWORD_FIELD_NAME, "_secret"); // this does an AND between the previous 2 clauses // it also puts a clause back on the stack where.and(2); where.eq(Account.NAME_FIELD_NAME, "bar"), where.eq(Account.PASSWORD_FIELD_NAME, "qwerty"))); // this does an AND between the previous 2 clauses // it also puts a clause back on the stack where.and(2); // this does an OR between the previous 2 AND clauses where.or(2);
来源:https://stackoverflow.com/questions/23270641/ormlite-parenthesis-in-join-where-clauses