1

I have the following SQL table containing a group ID, and the users that needs access to the groups. I have 3 types of users, but if it is the same user in all 3 types, then I only need to select 1 and not all 3.

This is my table:

This is my table:

And this is the result I would like from the select

Result

Any help is appreciated :)

OJ Slott
  • 75
  • 6

1 Answers1

2

You can use 3 selects with union:

select group_id,
       csp
  from your_table
union
select group_id,
       ep
  from your_table
union
select group_id,
       em
  from your_table
order by 1, 2;

Union will eliminate the duplicates.

Kapitany
  • 1,319
  • 1
  • 6
  • 10