I'm using PostgreSQL and I have a table that I'm keeping my users, and in another table, I'm keeping a user's group that contains id and group's name. In the user's table, I have a column that I save each user's group id in an array. Now I want to get all data from users and the name of the groups for each user. How should I do it? here is an example: user table :
user_id name roles
1 bob [1, 2]
2 jack [3]
role table:
role_id name
1 ceo
2 cto
3 financial
and I expect to have :
user_id name role_name
1 bob CEO, cto
2 jack financial