mysql - Join 3 tables to get single row -


i'm trying join multiple table single row result each id. result send angular ui

i have 3 tables user, friends , trip user can have multiple friends 1 trip

i details corresponding user in 1 row, friends field array?

this how table looks.

http://sqlfiddle.com/#!9/0879d/2

https://gist.github.com/tomalex0/9dee4fff85583732e7d0

group_concat should trick you:

select    u.*, t.*, friendlist      user u left join trip t on u.id = t.user_id left join (select   user_id, group_concat(concat (name, '- ', email)) friendlist                friends            group user_id) f on f.user_id = u.id 

Comments