How to search a MySQL database for a specific string
Posted
by Nadia
on Stack Overflow
See other posts from Stack Overflow
or by Nadia
Published on 2010-03-21T02:57:20Z
Indexed on
2010/03/21
3:01 UTC
Read the original article
Hit count: 259
I am trying to set up a search feature on my site that will only return exact matches to keyword entered by the user. So if the user searches "dog" I don't want an article titled "Doggy Style" to appear in the search results (just an example I don't really have an article by that name). This of course does exactly that:
SELECT * FROM articles WHERE article_title LIKE '%$searchQuery%'
$searchQuery here is a PHP variable taken from the user's input form. So is there any way to return only exact matches?
© Stack Overflow or respective owner