Laravel (FIND_IN_SET) Find A Value From Comma Separated Record In A Table.

Finding or checking a value from a comma separated record in a table. 

In users table we have multiple comma seprated value of currency_code like USD,INR,GBP.So will try to find all users who have USD as currency_code.

We will use FIND_IN_SET feature to filter datas.

User::where(['status'=>1])->whereRaw("FIND_IN_SET("USD",currency_code)")->get();

 

Leave a reply

your email address will not be published. required fields are marked *

Name *
Email *
Website