How to match exact string in a mysql database with imploded string
In this blog, you will learn how to match exact data in a MySQL database when you kept your data with multiple values in a single column by adding a comma between them.
We need this type of requirement when we insert data by using implode method in PHP, Codeigniter or laravel, and then we want to filter data from the database, we got blank; how to match exact data in a bunch of string, so here is the solution for you let’s see:
Suppose you have stored such type of data in MySQL column and you want to find out 14 from this string.
SELECT * FROM `your-tablename` WHERE your-column-name REGEXP '[[:<:]]".14."[[:>:]]'
In the above query replace your-tablename with your table name, replace your-column-name with your column name, and between REGEXP we have written 14 because we want to match 14 in a bunch of strings.
You can put the string which you want to match.