Here is a crazy example today, how to use find_in_set() mysql function in laravel query builder. If you need to add tags or something that store as comma separated values in database column, then you can simply store but if also need to search then it can be hard.
Like if you have posts table with tags column you simply store data like "laravel,php,html" etc comma separated string then how you found records only tags belong to laravel. So at that moment we can use mysql find_in_set() and we can use this function using whereRaw() of laravel query builder. So let's bellow bellow syntax and example.
Syntax:
FIND_IN_SET(needle,haystack);
Example:
$data = \DB::table("posts")
->select("posts")
->whereRaw("find_in_set('laravel',tags)")
->get();
I hope you found your best.....
Do you like below Tutorials ?
- Angular 9 HttpClient Request with RxJS Observable Example
- How to Create Routing Module in Angular 9?
- How to Create Custom Directive in Angular 9?
- Print Iframe Content using JQuery Example
- Allow Only Numeric Values in Textbox using JQuery
- Codeigniter Confirmation Box Before Delete Item Example
- How to Use Sweet Alert in Codeigniter?
- Disable F5 Key And Browser Refresh Using Javascript