我试图以查询目的运行查询,并且其行为方式无法解决。如果有人可以帮助我,至少我可以安然入睡
表数据如下
Table1
-------
account_no|consumer_domain_name|system|search_text|status
AB00001 |XY00001 |Linux | Null |active
AB00002 |XY00002 |Sybase| Null |partial-active
Table2
------
consumer_domain_name|
XY00001 |
XY00002 |
Table3
------
custodian_user_id|consumer_domain_name|
user-test1 |XY00001 |
user-test2 |XY00002 |
SELECT * FROM table1 a INNER JOIN table2 cad ON a.consumer_domain_name =
cad.consumer_domain_name
INNER JOIN table3 c ON c.consumer_domain_name = cad.consumer_domain_name
WHERE
LOWER(a.status) LIKE "%active%"
OR (LOWER(a.search_text) = LOWER("")
OR LOWER(c.custodian_user_id) = LOWER("")
OR LOWER(a.system) = LOWER(""))
所以我遇到的问题是,如果第二个条件,即
LOWER(a.search_text) = LOWER("")
OR LOWER(c.custodian_user_id) = LOWER("")
OR LOWER(a.system) = LOWER("")
在任何陈述中都是正确的
LOWER(a.search_text) = LOWER("")
OR LOWER(c.custodian_user_id) = LOWER("user-test1")
OR LOWER(a.system) = LOWER("")
它应该显示
custodian_user_id|account_no|consumer_domain_name|system|status
user-test1 |AB00001 |XY00001 |Linux |active
其他
custodian_user_id|account_no|consumer_domain_name|system|status
user-test1 |AB00001 |XY00001 |Linux |active
user-test2 |AB00002 |XY00002 |Sybase|partial-active
我有一个在多个字段上具有多个联接和多个条件的查询。条件可以归类为2个要检查的主要条件,例如(a)OR(x或y或z)……我真正想做的是,如果条件x,y,z都不是如果是true,则运行条件'a',否则运行'x或y或z'...即使x,y,z中的一个为true,它也始终运行a...。如果有人可以指出我的意思,我将不胜感激。正确的方向。谢谢
答案 0 :(得分:0)
您可以尝试以下方法:
public static String getJsonStringForPath(String strJson, String strJPath)
{
Configuration JACKSON_JSON_NODE_CONFIGURATION = Configuration.builder().jsonProvider(new GsonJsonProvider())
.options(Option.ALWAYS_RETURN_LIST, Option.SUPPRESS_EXCEPTIONS).build();
Configuration conf = Configuration.builder().jsonProvider(new GsonJsonProvider())
.options(Option.ALWAYS_RETURN_LIST, Option.SUPPRESS_EXCEPTIONS).build();
JsonArray objArrJ = JsonPath.using(conf).parse(strJson).read(strJPath);
String strRetJson = ""+objArrJ;
return strRetJson;
}
//Pass the param of JsonPath : "$.environment[*].red"
此查询的解释为:
WHERE
(x = 'value1' OR y = 'value2' OR z = 'value3') OR
((x != 'value1' and y != 'value2' and z != 'value3') and a = 'value4')
或
a = 'value4'