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:

Example:

144,14,44,441,143,1454

Suppose you have stored such type of data in MySQL column and you want to find out 14 from this string.

Solution:

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.

Categories: web development codeigniter mysql

Trending Courses

CodeIgniter

Regular : 45 Days

Fastrack : 20 Days

Crash : 10 Days

Advance Digital Marketing

Regular : 6 Months

Fastrack : 3 Months

Crash : 2 Months

React JS

Regular : 45 Days

Fastrack : 25 Days

Crash : 15 Days

Laravel

Regular : 45 Days

Fastrack : 20 Days

Crash : 10 Days

Front End Developer

Regular : 6 Months

Fastrack : 4 Months

Crash : 2 Months

Request For Demo