gpt4 book ai didi

java - ORMLite - 连接 where 子句中的括号

转载 作者:行者123 更新时间:2023-11-30 11:19:22 24 4
gpt4 key购买 nike

我想使用 QueryBuilder.joinQueryBuilder.joinor 连接三个表,但我想在 where 子句中使用括号,如下所示:

WHERE first_table_where AND (second_table_where OR third_table_where)

但这似乎是不可能的。

也许我遗漏了什么。任何帮助将不胜感激。

最佳答案

我猜那是一个 part of the doc你一直在寻找...

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);

关于java - ORMLite - 连接 where 子句中的括号,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/23270641/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com