Jump to content

Archived

This topic is now archived and is closed to further replies.

gurechan

like command

Recommended Posts

Hi, I'm trying to set up a search form and using the LIKE command in MySQL, ie:

SELECT * FROM books WHERE title LIKE '%$search%'

Now say I have a heap of books that have the work [b]book [/b]in the title, this query works fine if you enter book in the search field, but if you enter [b]books [/b]you get no results.

Is there an easy way to get it to still find a match.

Share this post


Link to post
Share on other sites
http://mysql.com/doc/refman/5.0/en/pattern-matching.html

SELECT * FROM books WHERE title LIKE '$search%'

Share this post


Link to post
Share on other sites
Nope -- there's no easy way; you can hack and remove the trailing "s" and try the query again, but it's kludgy at best.

Share this post


Link to post
Share on other sites

×

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.