using LIKE against 2 columns

computerpro

In Runtime
Messages
238
I am trying to check 2 columns for a particular pattern.

Here is the code:

$query = "SELECT * FROM pages WHERE title LIKE '%$v%' OR desc LIKE '%$v%'";


The error I got

Query failed: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'desc LIKE '%testsearch%'' at line 1


I need to check the same columns, well actually 3 columns, all for the same variable value.

If I take out the OR and thereafter, it works, but I need that.

Any ideas?
 
thats very strange, that query works when i try it...

did you copy the SQL from your php or did you re-write it here?
what happens if you print the SQL to the screen?

it the error points to a typing mistake perhaps putting ' or '' (' ') instead of ".??
 
Back
Top Bottom