How to use Group Concat in laravel Joining | Laravel Group By | Laravel 8 | Learning Points
HTML-код
- Опубликовано: 10 сен 2024
- How to display comma separated value | How to display multiple value in a single column | How to use Group Concat in laravel Joining | Laravel Group By | Laravel 8 | Learning Points
In this video we will learn about -
How we can use group by in joining
How to use pivot table
Use of order by in query
How to display comma separated value
How to display multiple value in a single column
Use of Having Clause in group by
Add clause in groupby
Join 3 tables where one is pivot table and others are master table
Laravel, Laravel 8, Laravel Tutorial
Please comment your feedback and support me by subscribing to this channel.
Laravel 9 New upgrades : • Laravel 9 New Features...
Laravel 9 Tutorial : • Laravel 9 Tutorial | C...
Express JS Tutorial : • Express Js Tutorial | ...
Full Node Js Tutorial : • Node JS latest version...
Full JWT Authentication tutorial in Laravel 8 : • Laravel 8 REST API Usi...
Full PHP tutorial : • PHP beginners to advan...
Full ECMA Script Tutorial : • ES6 | ECMA SCRIPT Tuto...
Laravel 8 tutorial : • Laravel 8 tutorial | L...
Angular Tutorial : www.youtube.co...
API tutorial with Laravel : • API tutorial from begi...
Livewire Tutorial : www.youtube.co...
Full Stack Application Tutorial : • Full Stack Application...
Full Voyager admin panel tutorial: www.youtube.co...
Advance PHP tutorial : • Advance PHP tutorial |...
PHP Interview Questions Answers : www.youtube.co...
Follow in Facebook : / learningpointsdotin
Follow in Linkedin : / learning-points
Follow in Instagram : / learning_points
Visit Learning Points website for more topic : learning-points...
#laravel #laravel8 #laravel8x #query #joining
Thanks a lot. Brother
nice, thank you
Welcome 😊
thanks.. i solved my problem
Great. Nice to hear that.
Thank you. very helpful video. 👍
Thank You
Hi, i have multiple relation. I would like to return all the data of nested relation. One user can have many project and one project can have many record (monthly update report). I would like return all the related relation based on reference user id. I would like the ppr_data groupby project_id. I try it but it only return the ppr_data group by project id. The other relation with user does not return. How can return all the data related with user but only the ppr-data group by project_id with latest report other return like usual ?
Here is how i return the user data. How can return all these data while the ppr_data is group by project id. Now the all the ppr_data of each project based on reference user id is return together without seperate by the project id.
public function getdata($id)
{
$user = User::with('manager', 'agency_type','project','ppr_data')->where('id', $id)->first();
return response()->json($user);
}
Need to check relation bro.
@@LearningPointsCourses Hi, here is the user model
public function project()
{
return $this->hasMany(Project::class, 'user_id', 'id');
}
public function manager()
{
return $this->hasOne(Manager::class, 'id', 'manager_id');
}
public function agency_type()
{
return $this->hasOne(AgencyType::class, 'id', 'agency_type_id');
}
public function ppr_data()
{
return $this->hasManyThrough(
PPRData::class,Project::class,'user_id', 'project_id', 'id', 'id' );
}
@@LearningPointsCourses Here is project model
public function user()
{
return $this->hasOne(User::class, 'id', 'user_id');
}
public function ppr_data()
{
return $this->hasMany(PPRData::class, 'project_id', 'id');
}
SQLSTATE[42000]: Syntax error or access violation: 1055 'students.name' isn't in GROUP BY
In Group By option we can group with any common section which are common in one or more rows, using student name we can't group by. Can you paste your query here?
How to concat first-name and last-name of tables?
If you simple use DB query then can use - DB::raw("CONCAT(students.firstName,' ',students.lastName) as StudentName")
Or If you use eloquent then create a function in model and call this -
public function fullName() {
return $this->firstName . ' ' . $this->middleName . ' ' . $this->lastName;
}
$students->fullName();
@@LearningPointsCourses Thank you so much!!
@@geetaninawe4897 Welcome :)
Hi, if want to group.by the degree name?
Yes sure you can do this. Make sure you are using degree in select statement and inside group by clause.
@@LearningPointsCourses is it just replace the student_degree.id with student_degree.name in group by ? Sorry, because i am quite blurr
Can you send me your query and tables through facebook link. Link provided on the video description section.
@@LearningPointsCourses can d thank you
You can't group by with sources_name. But you can group by with sources_id.
Hy sir , can i get Source code pliss
Sorry dear. I have not saved that code.
I hate groups 🙄
Yes but sometime we can't avoid.
I am getting "Column not found: 1054 Unknown column 'gl.testitem' in 'field list' while trying group concat
this is my select ->select('g.*',DB::raw('GROUP_CONCAT(gl.testitem) as testitems'))
and i am grouping by (g.id).
P.S- i am getting correct response in mysql group_concat
Need help