group_concat, account_id , .
SELECT contact_id, group_concat(account_id) FROM contacts_accounts GROUP BY contact_id;
Not sure what you need, but group_concat is faster than the subqueries I found, and there are more arguments that you can parse for group_concat if the above request does not meet your requirements.
source
share