Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/mysql/70.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
MySQL如果和或_Mysql_If Statement - Fatal编程技术网

MySQL如果和或

MySQL如果和或,mysql,if-statement,Mysql,If Statement,我已创建此查询: Where (companies.col_335 <> NULL) And (companies.col_285 = '') Or (companies.col_346 <> 'Yes') Or (companies1.col_275 = '') Or (companies1.col_294 <> 'Yes') 在哪里 (companys.col_335 NULL)和 (companys.col_285='')或 (c

我已创建此查询:

Where
  (companies.col_335 <> NULL) And 
  (companies.col_285 = '') Or
  (companies.col_346 <> 'Yes') Or
  (companies1.col_275 = '') Or
  (companies1.col_294 <> 'Yes')
在哪里
(companys.col_335 NULL)和
(companys.col_285='')或
(companys.col_346“是”)或
(公司1.col_275=“”)或
(公司1.col_294“是”)
我希望选择仅包括上面第一个比较为真的记录,以及其他5个比较中至少一个为真的记录


这是正确的方法吗?

您缺少一些括号:

Where
  (companies.col_335 <> NULL) And 
  (companies.col_285 = '' Or
  companies.col_346 <> 'Yes' Or
  companies1.col_275 = '' Or
  companies1.col_294 <> 'Yes')
在哪里
(companys.col_335 NULL)和
(companys.col_285=''或
公司。col_346“是”或
companies1.col_275=''或
公司1.col_294“是”)
你想做的是先做,然后再做,或者用最后三个中的任何一个。即:

(companies.col_335 <> NULL And companies.col_285 = '')
Or
  companies.col_346 <> 'Yes' 
Or
  companies1.col_275 = '' 
Or
  companies1.col_294 <> 'Yes'
(companys.col_335为空,companys.col_285为空)
或
公司。col_346“是”
或
公司1.col_275=''
或
公司1.col_294“是”

您缺少一些括号:

Where
  (companies.col_335 <> NULL) And 
  (companies.col_285 = '' Or
  companies.col_346 <> 'Yes' Or
  companies1.col_275 = '' Or
  companies1.col_294 <> 'Yes')
在哪里
(companys.col_335 NULL)和
(companys.col_285=''或
公司。col_346“是”或
companies1.col_275=''或
公司1.col_294“是”)
你想做的是先做,然后再做,或者用最后三个中的任何一个。即:

(companies.col_335 <> NULL And companies.col_285 = '')
Or
  companies.col_346 <> 'Yes' 
Or
  companies1.col_275 = '' 
Or
  companies1.col_294 <> 'Yes'
(companys.col_335为空,companys.col_285为空)
或
公司。col_346“是”
或
公司1.col_275=''
或
公司1.col_294“是”
否(基本布尔逻辑)。使用括号将其正确执行:

Where
  (companies.col_335 <> NULL) And 
  ((companies.col_285 = '') Or
  (companies.col_346 <> 'Yes') Or
  (companies1.col_275 = '') Or
  (companies1.col_294 <> 'Yes'))
在哪里
(companys.col_335 NULL)和
((companys.col_285='')或
(companys.col_346“是”)或
(公司1.col_275=“”)或
(公司1.col_294“是”)
否(基本布尔逻辑)。使用括号将其正确执行:

Where
  (companies.col_335 <> NULL) And 
  ((companies.col_285 = '') Or
  (companies.col_346 <> 'Yes') Or
  (companies1.col_275 = '') Or
  (companies1.col_294 <> 'Yes'))
在哪里
(companys.col_335 NULL)和
((companys.col_285='')或
(companys.col_346“是”)或
(公司1.col_275=“”)或
(公司1.col_294“是”)

你就快到了。。。你应该围绕在或部分

WHERE 
    (companies.col_335 <> NULL)
    AND
    (
        (companies.col_285 = '') Or
        (companies.col_346 <> 'Yes') Or
        (companies1.col_275 = '') Or
        (companies1.col_294 <> 'Yes')
    )
在哪里
(companys.col_335空)
及
(
(companys.col_285='')或
(companys.col_346“是”)或
(公司1.col_275=“”)或
(公司1.col_294“是”)
)

你就快到了。。。你应该围绕在或部分

WHERE 
    (companies.col_335 <> NULL)
    AND
    (
        (companies.col_285 = '') Or
        (companies.col_346 <> 'Yes') Or
        (companies1.col_275 = '') Or
        (companies1.col_294 <> 'Yes')
    )
在哪里
(companys.col_335空)
及
(
(companys.col_285='')或
(companys.col_346“是”)或
(公司1.col_275=“”)或
(公司1.col_294“是”)
)

谢谢你,巴特。这是意料之中的事。也感谢奥雷尔和菲利佩的帮助。谢谢,巴特。这是意料之中的事。还要感谢Orel和Filipe的帮助。