Query Builder: Get value of an aggregated field

 
<?php

$names = DB::table('users')
    ->select(DB::Raw('group_concat(name) as names'))
    ->where('id', '<', 10)
    ->value('names');

?>

 

Related Snippets

•  Database: Insert, Update, Delete
•  Query Builder: Insert, Update, Delete
•  Validation: Validator
•  Database: Raw SQL Select Query
•  Query Builder: Get single value of a field from one record
•  Database: Using PDO