Normally I use a simple query first, then combine the queried results with programming, when the name in the next record is the same with current record, group them into one object (string, etc. according to your code), if they are different, finish current record and start a new one.
SQL query: select Name, Friends from table_name order by Name
|