如何在mysql中搜索以逗号分隔的多个值 [英] How to search mulitple value seperated by commas in mysql
本文介绍了如何在mysql中搜索以逗号分隔的多个值的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
如何搜索以逗号分隔的多个值.
How to search multiple values separated by commas.
例如:
表名:searchTest
id name keyword
1 trophy1 test1,test2,test3
2 trophy2 test2,test5
积分:
如果我搜索 test2,结果 trophy1 和 trophy2 都应该显示.
If i search for test2 both results trophy1 and trophy2 should be display.
如果我搜索 trophy1,那么 trophy1 应该是结果.
If i search for trophy1 then trophy1 should be as result.
如何解决这个问题.
提前致谢
推荐答案
你可以使用like.
select * from searchTest where keyword like '%test2%'
其中 % 是通配符.
这篇关于如何在mysql中搜索以逗号分隔的多个值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文