I'm trying to query for a list of person's names and all their friends from my database. I need their list of friends to be in an array adjacent to their row for formatting purposes.
Here is my query:
$sql = "SELECT CONCAT(r.first_name, ' ', r.last_name) as name,
( SELECT CONCAT(first_name, ' ', last_name) as friend_name
FROM friend_list WHERE friend = r.id) as friends
FROM friend_list r";
Because people have multiple friends, I need this to return an array of friends for each person. how would I do this?