I have tables as below:
Suits
| id | hotel_id | name | etc ...
1 3 Some name
2 3 SomeName2
Orders
| id | suits | etc ...
1 1,2
I want to get order list from database with suit names as below:
| id | hotel_id | suits | etc ...
1 3 Some name, SomeName2
I'm trying with this code:
SELECT
o.id,
h.name as hotel,
o.hotel as hotel_id,
s.name
FROM h_orders o
LEFT JOIN hotels h ON o.hotel = h.id
LEFT JOIN suits s ON o.suits = s.id
WHERE o.user_id = ? GROUP BY o.id ORDER BY o.id DESC
But getting only first suit name. How can I get result as mentioned above? Thanks in advance.