Go Back   Computer Forums > Web Design | Website Development > Web Programming
Click Here to Login
Join Computer forums Today


Reply
 
Thread Tools Search this Thread Display Modes
 
Old 10-28-2005, 08:11 PM   #1
In Runtime
 
computerpro's Avatar
 
Join Date: Nov 2004
Posts: 231
Default using LIKE against 2 columns

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?
__________________

computerpro is offline   Reply With Quote
Old 10-31-2005, 07:23 AM   #2
Site Team
 
root's Avatar
 
Join Date: Mar 2004
Posts: 7,999
Default Re: using LIKE against 2 columns

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 ".??
__________________
I didn’t fight my way to the top of the food chain to be a vegetarian…
Im sick of people saying 'dont waste paper'. If trees wanted to live, they'd all carry guns.
"The inherent vice of capitalism is the unequal sharing of blessings; The inherent vice of socialism is the equal sharing of miseries."
root is offline   Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off



All times are GMT -5. The time now is 04:30 PM.


Powered by vBulletin® Version 3.8.8 Beta 4
Copyright ©2000 - 2017, vBulletin Solutions, Inc.
Search Engine Friendly URLs by vBSEO 3.6.0