I have SQL code that has a condition BETWEENand OR.
SELECT * FROM tbl_order o INNER JOIN tbl_contacts c ON c.contacts_id = o.contacts_id LEFT JOIN tbl_title t ON t.title_id = c.title_id LEFT JOIN tbl_assign a ON (a.order_id = o.order_id AND a.order_no_first = o.order_no_first) WHERE o.order_status = 1 AND o.order_date BETWEEN DATE(DATE_ADD(o.order_date, INTERVAL -2 DAY) AND CURDATE()) OR o.order_print = 1 GROUP BY o.order_id
The above code throws an error,
#1064 - You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'OR o.order_print = 1 GROUP BY o.order_id LIMIT 0, 25' at line 1
If I use ANDinstead OR, the code works fine. But I need ORinsteadAND
How to resolve this error. Where am I mistaken?
source
share