I have two table:
CREATE TABLE roles(role_name varchar(255) primary key);
CREATE TABLE roles_permissions(permission varchar(100), role_name varchar(100));
here is result by :
SELECT * from roles;
role_name
-----------
role1
role2
(2 rows)
here is result by :
SELECT * from roles_permissions ;
role_name | permission
-----------+-------------
role1 | permission1
role1 | permission2
role2 | permission1
(3 rows)
----------------------------------------
-----------------------------------
after the command:
SELECT * from roles, roles_permissions;
role_name | role_name | permission
-----------+-----------+-------------
role1 | role1 | permission1
role1 | role1 | permission2
role1 | role2 | permission1
role2 | role1 | permission1
role2 | role1 | permission2
role2 | role2 | permission1
the expected result is:
role_name | permission
-----------+-------------
role1 | permission1,permission2,
&
nbsp;role2 | permission1
for short:
afer join of two table, here is some repeat columns,
I only want to a row for role1.