Reputation: 11
My table has
SNO VA
1 A
2 A
3 A
4 A
11 B
12 B
21 C
22 C
VAL has 3 possible values here. It could be any number upto 17 and the below output can have 17 values joines together. Example here is with 3 values
And I need my output as
1,11,21
1,12,21
1,11,22
1,12,22
2,11,21
2,12,21
2,11,22
2,12,22
3,11,21
3,12,21
3,11,22
3,12,22
4,11,21
4,12,21
4,11,22
4,12,22
Upvotes: 1
Views: 37
Reputation: 311913
This is a cross join on the same table thrice:
SELECT a.sno, b.sno, c.sno
FROM mytable a
CROSS JOIN mytable b
CROSS JOIN mytable c
ON a.val = 'A' AND b.val = 'B' AND c.val = 'C'
Upvotes: 1