MySQL Forums
Forum List  »  PHP

MySQL Query With LIKE variable
Posted by: Michael O'Connor
Date: March 31, 2007 04:48PM

Hi there, I'm fairly new to MySQL,but I've searched all over the internet for an answer to this question, but have been unable to find one. So, I'm trying to make a query like so:

$query = "SELECT title, keywords, url FROM table WHERE keywords LIKE '%mysql%'";

That works fine, however, I would like to replace mysql with a variable, changing it into something like this:


$query = "SELECT title, keywords, url FROM table WHERE keywords LIKE '%$keyword%'";

I have been unable to figure out how to do this so far. it works if I take out the %'s, but that somewhat defeats the purpose.

Thanks for your help.

Options: ReplyQuote


Subject
Written By
Posted
MySQL Query With LIKE variable
March 31, 2007 04:48PM


Sorry, you can't reply to this topic. It has been closed.

Content reproduced on this site is the property of the respective copyright holders. It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.