By using db<>fiddle, you agree to license everything you submit by Creative Commons CC0.
create table test (Id char);
insert into test values('A');
1 rows affected
insert into test values('B');
1 rows affected
insert into test values('C');
1 rows affected
insert into test values('D');
1 rows affected
insert into test values('E');
1 rows affected
select a.id, b.id from test a cross join test b where a.id<>b.id;
ID | ID |
---|---|
A | B |
A | C |
A | D |
A | E |
B | A |
B | C |
B | D |
B | E |
C | A |
C | B |
C | D |
C | E |
D | A |
D | B |
D | C |
D | E |
E | A |
E | B |
E | C |
E | D |