ORMLite - Parenthesis in join where clauses

百般思念 提交于 2019-12-07 18:52:15

问题


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) and Where.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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!