Concat Column Data In Sql Laravel

[Solved] Concat Column Data In Sql Laravel | Php Frameworks Laravel - Code Explorer | yomemimo.com
Question : concat column data in sql laravel

Answered by : christian-racuya

//must have
use Illuminate\Support\Facades\DB;
Model::select(DB::Raw("CONCAT(profiles.first_name, ' ', profiles.last_name) AS name"))->get();
//concat other table data and display as one line with ',' as a delimiter
//DB::Raw("(SELECT GROUP_CONCAT(a.contact_number) FROM contacts as a JOIN users as b ON a.user_id = b.user_id WHERE a.user_id = users.user_id) AS contact")
//expected output would be 09123456789,09876543210,09000000000

Source : https://stackoverflow.com/questions/42735071/concat-columns-with-laravel-5-eloquent | Last Update : Wed, 01 Jun 22

Answers related to concat column data in sql laravel

Code Explorer Popular Question For Php Frameworks Laravel