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 关键字括起来
posted @ 2017-10-20 15:30  音神  阅读(1474)  评论(0编辑  收藏  举报