请问MSSQL语句中这样写为什么不对?应该怎么写啊??

select * from Table where Branch1 is Null and Branch2 not like '%"不同意"%' or Branch3 not like '%"不同意"%' order by AddTime desc


我想查询出来Branch1字段为空,并且Branch2字段不包含不同意,或者Branch3字段不包含不同意的内容的所有记录,但查出来的记录是Branch1未空并且Branch2包含有不同意的内容的记录,这个语句到底应该怎么写啊??

问题找到啦,是因为Branch2字段里是null不是空,所以查询语句出现问题,但还是谢谢你们!

加括弧试试,select * from Table where (Branch1 is Null and Branch2 not like '%"不同意"%' )or (Branch3 not like '%"不同意"%' )order by AddTime desc

不知道你不同意前后的双引号什么用,没意义就去掉吧。
 select * from Table where Branch1 is Null and Branch2 not like '%不同意%' or Branch3 not like '%不同意%' order by AddTime desc

1不同意字符串两边的引号不要
2条件判断中and后面属于一个条件放到括号中