SQL语句AND 和 OR执行的优先级
例句:
SELECT COUNT(1) FROM RT_CUSTALLOCRESULT WHERE REGDATE BETWEEN '2014-03-01' AND '2014-03-31' OR (DATE(NEXTTRACKDATE) BETWEEN '2014-03-01' AND '2014-03-31') AND SALEID = 2003
SELECT COUNT(1) FROM RT_CUSTALLOCRESULT WHERE (REGDATE BETWEEN '2014-03-01' AND '2014-03-31' OR (DATE(NEXTTRACKDATE) BETWEEN '2014-03-01' AND '2014-03-31')) AND SALEID = 2003
没带括号前,优先执行
(DATE(NEXTTRACKDATE) BETWEEN '2014-03-01' AND '2014-03-31') AND SALEID = 2003
带了括号后,优先执行
(REGDATE BETWEEN '2014-03-01' AND '2014-03-31' OR (DATE(NEXTTRACKDATE) BETWEEN '2014-03-01' AND '2014-03-31'))