Skip to content
Advertisement

Laravel – DB::TABLE SQL – how to get join data in one queries

I Have 2 tables first client_group with data like below

enter image description here

second table client

enter image description here

in Controller I have code like below:

From this query i have results like below:

client_id is always in one column (“client_id”: “8,14,22”) because is added like this. Now is my question and issues, how to change view and query to get insted of one email all clients emails? based on client_id, below current view. At the moment I have only one email first from client_id lists

enter image description here

Advertisement

Answer

First of all , use FIND_IN_SET to join table with comma separated values. Something like this-

And in the blade file you can get client emails like this- {{ $row->client_emails }}

User contributions licensed under: CC BY-SA
7 People found this is helpful
Advertisement