Laravel

Find_in_set in Laravel (search comma-separated value from table column)

In this article, we will learn about how we can find search for comman separated value using find_in_set using laravel eloquent.sometimes we save our data in comma seperated pattern and we will try to get that data using where and we are unable to get that, to search in comma separted column we have to use find_in_set.

You will know more about find_in_set from here.

Below is the syntax of find_in_set

FIND_IN_SET(needle,haystack);

Now you can see the below image, which had data with comma-separated, let’s see how we can get data from that table.

find_in_set
table having comma separated value in column

Read Also: Multiple Image Upload In Laravel 8

Now we are going to use the below code to get all the data using Laravel Eloquent.

$class = '8a';
teacherMeetingDetails::whereRaw('find_in_set("'.$class.'",class)')->get();

This will return all data, where your comma separted value is matched.here teacherMeetingDetails is model of teacheMeetingDetails table.

Shaiv Roy

Hy Myself shaiv roy, I am a passionate blogger and love to share ideas among people, I am having good experience with laravel, vue js, react, flutter and doing website and app development work from last 7 years.

Related Articles

Leave a Reply

Your email address will not be published. Required fields are marked *

Back to top button