0

I have 2 tables Transporter and Cars ,

enter image description here

I want to display all cars for a single Transporters in a single row

using joins I am getting cars all but in different row

enter image description here

I tried Group by clause but it is not working

enter image description here

What modifications Can i do in a query ?

Neeraj Verma
  • 2,174
  • 6
  • 30
  • 51

1 Answers1

0

Try using GROUP_CONCAT function like:

SELECT t.id, GROUP_CONCAT(car_name) AS Cars
FROM Transporters t INNER JOIN cars c
ON C.t_id = t.id
GROUP BY t.id


Output:
id Cars
1  car1,car3
2  car2,car4,car5
SMA
  • 36,381
  • 8
  • 49
  • 73