我已创建此查询:

Where
  (companies.col_335 <> NULL) And
  (companies.col_285 = '') Or
  (companies.col_346 <> 'Yes') Or
  (companies1.col_275 = '') Or
  (companies1.col_294 <> 'Yes')

我希望选择只包括上面第一个比较为真的记录,并且其他5个比较中至少有一个为真。
这样做对吗?

最佳答案

否。AND has higher precedence over OR(基本布尔逻辑)。使用圆括号将其正确执行:

Where
  (companies.col_335 <> NULL) And
  ((companies.col_285 = '') Or
  (companies.col_346 <> 'Yes') Or
  (companies1.col_275 = '') Or
  (companies1.col_294 <> 'Yes'))

10-02 01:30
查看更多