GROUP_CONCAT with different SEPARATOR in laravel ExampleBy Hardik Savani | January 20, 2016 | | 5417 Viewer | Category : Laravel MySql
Share this post:
Whenever, you need to use GROUP_CONCAT with differente separator(I mean default separator is ',', But you want to change '@','#','&' etc as you want). then you have to use use SEPARATOR keyword in GROUP_CONCAT(). If you are working on laravel then you have to also use DB::raw() for write GROUP_CONCAT() inside the this function.
So, Basically how to change seprator in group_concat(), In following example i change ',' separator into '@'.you can use the following example how to use in laravel 4 and 5.
$items = DB::table('items')
,DB::raw("(GROUP_CONCAT(items_city.name SEPARATOR '@')) as `cities`"))
- How to implement Email Verification with Activation Code example from Scratch in Laravel 5.2 ?
- How to add text on image in laravel 5?
- Laravel 5 Instagram API tutorial with example
- How to add charts in Laravel 5 using Chart JS ?
- How to check if record exists or not in Laravel 5?
- How to get Ip Address in Laravel 5?
- How to resolve laravel 5 blank page on server?
- How to add CKEditor with image upload using KCFinder in PHP Example Code?