concrete5 - SQL How do I use the parentheses correctly to separate the AND and OR statements? -


I'm not super awesome on SQL I'm filtering a solid 5 archive with the following and not sure it How to work all. How do I correctly use brackets to separate Android statements?

It does not do anything:

  $ this-> DATE_SUB (NOW (), INTERVAL 3 days) between filter (empty, "(3 days now) and now () DATE_SUB (expiration date, interval 30 days) and (DATE_SUB (expiry date, INTERVAL 5 days) and now ( ) Or dATE_SUB (now () (interval 3 days) between DATE_SUB (end date, interval 1 day) and now ()) and (DATE_ADD (warned, interval 4 days) & lt; = now ()) " );  

This one works mostly (Leaves removed brackets around the first statements of Android) but after that ... and "DATE_ADD (warned date, interval L 4 days) and lt; = NOW ()) ":

  $ this-> DATE_SUB (NOW) between filter (empty, "(DATE_SUB (expiry date, INTERVAL 30 days) between DATE_SUB (now () (INTERVAL 3 days) and now ()) or (DATE_SUB (end date, INTERVAL day 5) , INTERVAL 3 days) and now ()) or DATE_SUB (NOW (), INTERVAL 3 days) and now ()) and (DATE_ADD (warned, interval 4 days) between (DATE_SUB (expiry date, INTERVAL 1 day) & Lt; = NOW ()) "); As mentioned in the comments, two sections for 5 days and 1 day are redundant, as described in "Comments",  

  4 days) & lt; = NOW ())  

Note : and are used when both of you Correct and correct for at least one condition or .


Comments