简体   繁体   中英

FIND_IN_SET with like clause mysql

I have a MySQL table where I am using comma separated values like:

user_name      books
abc            PHP,Java
xyz            Net,Shift,PHP

I can handle comma-separated value searching using the FIND_IN_SET function of MySQL.

Now books names are auto suggested means if any one search with keyword "J" , system should search and match the word Java and give result of user "abc".

I tried to use like clause with FIND_IN_SET but it's not working. Does anyone have any suggestions?

这不是一个干净的解决方案,但是您可以使用以下方法:

SELECT * FROM `library` WHERE `books` LIKE 'J%' OR `books` LIKE '%,J%'

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