Sign Up

Sign In

Forget Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

You must login to ask question.

Developers Map

How to search with comma seperated value from database in laravel

  • 4

Laravel is a most common framework. it is very easy to use and learn. when we get data from database we require to manage to take single database column for multiple integer ids.when we store comma seperated ids in database but how can we search specific id data from comma separated column value in laravel.for this we can use “find_in_set()” predefined function.

Example :
1. $searchData = 1;
$data = \DB::table(“TABLENAME”)
->select(“TABLENAME.*”)
->whereRaw(“find_in_set(‘”.$searchData .”‘,DB_COLUMN_NAME)”)
->get();

2. $result = YOURTABLENAME::where(“YOUROTHERCONDITION”)->whereRaw(“find_in_set(‘”.$searchData .”‘,DB_COLUMN_NAME)”)->get();

For More Infomation CLICK HERE

Leave an answer

Leave an answer

Browse