Possible with one MySQL query? "column contains any of the array's values" -
basically want check whether mysql text column, contains comma-separated values, contains of values contained in array. know can done loop , multiple queries, hoping single query. possible? thank you.
i use solution this:
select * yourtable str rlike concat('[[:<:]]', replace('values,in,the,array', ',', '[[:>:]]|[[:<:]]'), '[[:>:]]')
this make following string:
'values,in,the,array'
like this:
[[:<:]]values[[:>:]]|[[:<:]]in[[:>:]]|[[:<:]]the[[:>:]]|[[:<:]]array[[:>:]]
[[:<:]]
, [[:>:]]
word boundaries match whole words, , | or match of words. please see fiddle here.
Comments
Post a Comment