sql语句 使用 or 关键字遇到的问题

select * from a where 1=1 (and a.id is null or a.id = 0) 执行出错
select * from a where 1=1 and (a.id is null or a.id = 0) 执行正常

说明1:使用 or 关键字最好要用括号把条件括起来
说明2:前置括号放置 and 关键字之后,一定不要把 and 关键字括起来
原文地址:https://www.cnblogs.com/gc-note/p/7699751.html