简体   繁体   中英

Search specific keyword MySQL

What's the best way to find a specific keyword?

I combine php and the mysql LIKE '%xxxxx%' function to search articles. When I try to search a keyword for example 'HP' I get al the results containing this keyword, so an article whichs has 'PHP' in it also appears.

What's the best way to avoid this or does anybody have a workaround, method for this? I've tried al the other MySQL operators but no luck so far. Through REGEXP my search results were getting much better but I got still things in it that didn't belong there.

mySQL fulltext search may be for you, however that has some limitations too - most importantly, a 3-character minimum for keywords. So you couldn't search for "HP" without changing mySQL's server configuration to lower the minimum.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM