Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do you OR two LIKE statements?

Tags:

sql

mysql

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.

like image 896
Thomas Owens Avatar asked Oct 27 '08 16:10

Thomas Owens


People also ask

Can we use multiple like in SQL?

No, MSSQL doesn't allow such queries.


1 Answers

SELECT col FROM db.tbl WHERE (col LIKE 'str1' OR col LIKE 'str2') AND col2 = num 
like image 195
Tom Ritter Avatar answered Sep 23 '22 13:09

Tom Ritter