How to compare two logical expressions from SQL, where is the condition?

I want two comparisons of the two SQL where the items were to check if the conditions are the same.

In the example below, SQL queries have the same logical conditions in the where clause. What operation should tell me that both condition conditions are logically the same?

Is there a REGEX for this? Any other approach?

String Q3 = "select t1.ID as ID,t1.FIELD8 as I_RECHARGE_TYPE,t1.FIELD28 as I_RECHARGE_AMOUNT,t1.FIELD1 as I_ACTIVATION_DATE,t1.FIELD2 as I_MSISDN from INSTANT_CDR_0 as t1 where t1.FIELD2 = ? and ((((t1.FIELD8 IS NOT NULL  AND  t1.FIELD28 > 0) OR  DATE_FORMAT(t1.FIELD1,'%Y-%m-%d') > '2016-05-21')) or ((DATE_FORMAT(t1.FIELD1,'%Y-%m-%d') < '2015-12-03' OR ( t1.FIELD28 > 0 AND  t1.FIELD28 < 101))))";
String Q4 = "select t1.ID as ID,t1.FIELD1 as I_ACTIVATION_DATE,t1.FIELD8 as I_RECHARGE_TYPE,t1.FIELD28 as I_RECHARGE_AMOUNT,t1.FIELD2 as I_MSISDN from INSTANT_CDR_0 as t1 where t1.FIELD2 = ? and (((DATE_FORMAT(t1.FIELD1,'%Y-%m-%d') > '2016-05-21' OR ( t1.FIELD8 IS NOT NULL  AND  t1.FIELD28 > 0))) or (((t1.FIELD28 > 0 AND  t1.FIELD28 < 101) OR  DATE_FORMAT(t1.FIELD1,'%Y-%m-%d') < '2015-12-03')))"; 

How to compare ((a=2) and (b=3))with ((b=3) and(a=2))and find out that they are the same?

+4
source share
2 answers

The simplest case would be if all the fields you had were logical. Thus, all logical expressions will also be Boolean expressions.

, , , , .

: A , B - , A and B - . A and B, , . , not (A and B) . , . , , . , , , , , .

, , SAT-, (, ).

, NP-complete. . , SAT-, , (, ?).

, SAT , SQL, . , .

, , .

, , : . , , . , , . , , . , , , , , , . , , , , . , . , , , /, , , , , , , - . , - 1000 , , , .

, . : ( DeMorgan, , ..), , , , where , .

, . , .

+2

/ , ( ). , NP-Complete...

  • - JSQLParser, , . , . / .

  • , where , . OR/AND ... , .

, , / ..

0

All Articles