完全不一样
where a='A' and b='B' or c='C'
其实是(a='A' and b='B') or c='C' (a必须等于'A',b必须等于'B' 这两个条件必须同时满足)
怎么可能和 a='A' and (b='B' or c='C') 一样。
a='A' and (b='B' or c='C')(a必须等于'A',b='B' 或者 c='C'任意成立都可以)
where a='A' and b='B' or b='C'与where a='A' and (b='B' or b='C')的区别。
where a='A' and b='B' or b='C'的查询结果是不是所有b='C'的纪录以及满足a='A' and b='B'条件的纪录的合集? 正确
where a='A' and (b='B' or b='C')的查询结果是不是所有a='A'并且b是'B'或'C'的纪录?正确
感谢大家捧场,呵呵
不过,真对不起,一时匆忙,写错了。而且我也自己试过了,只是不太确定,并想寻求理论依据,呵呵
其实,我想问的是where a='A' and b='B' or b='C'与where a='A' and (b='B' or b='C')的区别。
where a='A' and b='B' or b='C'的查询结果是不是所有b='C'的纪录以及满足a='A' and b='B'条件的纪录的合集?
where a='A' and (b='B' or b='C')的查询结果是不是所有a='A'并且b是'B'或'C'的纪录?
非常感谢。
where a='A' and b='B' or c='C'
where a='A' and (b='B' or c='C')
如果有c='C'的记录就不一样,反之结果一样
假设结果中有满足c='C'的记录,那么第一个查询出来的是所有c='C'的记录,不管a和b
而第二个查询出来的是c='C'与a='A'的交集,这就是不同
假设记录中没有满足c='C'的记录那么两个写法得到的结果一样