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.

Answer

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

Leave a Reply

Your email address will not be published. Required fields are marked *