Skip to content
Advertisement

How do you OR two LIKE statements?

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.

Advertisement

Answer

SELECT col FROM db.tbl WHERE (col LIKE 'str1' OR col LIKE 'str2') AND col2 = num
User contributions licensed under: CC BY-SA
6 People found this is helpful
Advertisement