I have this query:
SELECT * FROM (`users`) WHERE `date_next_payment` <= '2011-02-02'
AND `status` = 'active' OR `status` = 'past due'
Which does not return the correct results. However, adding parentheses around the OR conditions makes it work like so:
SELECT * FROM (`users`) WHERE `date_next_payment` <= '2011-02-02'
AND (`status` = 'active' OR `status` = 'past due')
My question is why is it different? I understand that's is considering the OR statement differently without the parentheses; but I don't understand how it's different.
I haven't found any docs that have been helpful on this. If there's any links out there I'd really appreciate it.
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…