tags:

views:

213

answers:

5

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.

+15  A: 
SELECT col FROM db.tbl WHERE (col LIKE 'str1' OR col LIKE 'str2') AND col2 = num
Tom Ritter
+1  A: 

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

Elie
+1  A: 

Think simple:

SELECT col FROM db.tbl WHERE (col LIKE 'str1' OR col LIKE 'str2') AND col2 = ...
Daniel Spiewak
+2  A: 

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

warren
+1  A: 

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.

Eclipse