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

Комментарии • 35

  • @kevinoropeza2830
    @kevinoropeza2830 3 месяца назад

    Thanks a lot. Brother

  • @Azil7136
    @Azil7136 Год назад +1

    nice, thank you

  • @shamimdewan2810
    @shamimdewan2810 2 года назад +1

    thanks.. i solved my problem

  • @HarshaBHerath
    @HarshaBHerath Год назад

    Thank you. very helpful video. 👍

  • @lingting9790
    @lingting9790 3 года назад

    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 ?

    • @lingting9790
      @lingting9790 3 года назад

      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);
      }

    • @LearningPointsCourses
      @LearningPointsCourses  3 года назад

      Need to check relation bro.

    • @lingting9790
      @lingting9790 3 года назад

      @@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' );
      }

    • @lingting9790
      @lingting9790 3 года назад

      @@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');
      }

  • @pansurna7
    @pansurna7 3 года назад

    SQLSTATE[42000]: Syntax error or access violation: 1055 'students.name' isn't in GROUP BY

    • @LearningPointsCourses
      @LearningPointsCourses  3 года назад

      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?

  • @geetaninawe4897
    @geetaninawe4897 3 года назад +1

    How to concat first-name and last-name of tables?

    • @LearningPointsCourses
      @LearningPointsCourses  3 года назад +1

      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();

    • @geetaninawe4897
      @geetaninawe4897 3 года назад +1

      @@LearningPointsCourses Thank you so much!!

    • @LearningPointsCourses
      @LearningPointsCourses  3 года назад +1

      @@geetaninawe4897 Welcome :)

  • @lingting9790
    @lingting9790 3 года назад

    Hi, if want to group.by the degree name?

    • @LearningPointsCourses
      @LearningPointsCourses  3 года назад

      Yes sure you can do this. Make sure you are using degree in select statement and inside group by clause.

    • @lingting9790
      @lingting9790 3 года назад

      @@LearningPointsCourses is it just replace the student_degree.id with student_degree.name in group by ? Sorry, because i am quite blurr

    • @LearningPointsCourses
      @LearningPointsCourses  3 года назад

      Can you send me your query and tables through facebook link. Link provided on the video description section.

    • @lingting9790
      @lingting9790 3 года назад

      @@LearningPointsCourses can d thank you

    • @LearningPointsCourses
      @LearningPointsCourses  3 года назад

      You can't group by with sources_name. But you can group by with sources_id.

  • @ramadanyosi8744
    @ramadanyosi8744 3 года назад

    Hy sir , can i get Source code pliss

  • @peleora112
    @peleora112 Год назад

    I hate groups 🙄

  • @aniketanand6420
    @aniketanand6420 Год назад

    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