你怎么两个语句吗?How do you OR two LIKE statements?

- 此内容更新于:2014-12-30
主题:

原文:

I have tried the following two statements:

  • SELECT col FROM db.tbl WHERE col (LIKE 'str1' OR LIKE 'str2') AND col2 = num results in a syntax error
  • SELECT col FROM db.tbl WHERE page LIKE ('str1' OR 'str2') AND col2 = num results in "Truncated incorrect DOUBLE value: str1" and "Truncated incorrect DOUBLE value: str2" for what looks like every result. However, no results are actually returned.

I figured one of the two statements would work, but they aren't.

解决方案:
原文:
SELECT col FROM db.tbl WHERE (col LIKE 'str1' OR col LIKE 'str2') AND col2 = num
解决方案:
我认为你需要在((像“str1”页)或(如“str2”)页)
原文:

I believe you need WHERE ((page LIKE 'str1') OR (page LIKE 'str2'))

解决方案:
试着从数据库选择坳。台的地方(像“str1”或坳坳像“str2”)和col2 =数字
原文:

try SELECT col FROM db.tbl WHERE (col LIKE 'str1' or col LIKE 'str2') AND col2 = num

解决方案:
认为简单:
原文:

Think simple:

SELECT col FROM db.tbl WHERE (col LIKE 'str1' OR col LIKE 'str2') AND col2 = ...
解决方案:
“或”操作符适用于表达式。“像str1”和“像str2”并不是有效的表达式,因为“喜欢”操作符需要左手边和右手边。 将首先尝试或一起‘str1’和‘str2’,给真正的价值。它将尝试并评估页面像真的,并报告一个错误。
原文:

The "OR" operator applies to expressions. "LIKE 'str1'" and "LIKE 'str2'" are not valid expressions, since the "LIKE" operator requires both a left hand side and a right hand side.

page LIKE ('str1' OR 'str2')

would first try to OR together 'str1' and 'str2', giving the value TRUE. It would then try and evaluate page LIKE TRUE, and report an error.