i want to create an algorithm or formula that gives me the following combinations below. I have manually printed out all the combinations for the example containing 4 tables with respective values.
This is not permutation because i need the combinations to always follow the unique format
Table1,Table2,Table3,Table4 values
So how can i achieve this in SQL script or through C# code (VB.Net code can also work)
Note: the solution contain all the possible 48 combinations i need for my problem.
Problem
Table1     Table2     Table3     
Table4
a1             b1           
c1             d1
a2             b2           
c2             d2
a3                            
c3
                                
c4
Solution
a1,b1,c1,d1
a1,b1,c1,d2
a1,b1,c2,d1
a1,b1,c2,d2
a1,b1,c3,d1
a1,b1,c3,d2
a1,b1,c4,d1
a1,b1,c4,d2
a1,b2,c1,d1
a1,b2,c1,d2
a1,b2,c2,d1
a1,b2,c2,d2
a1,b2,c3,d1
a1,b2,c3,d2
a1,b2,c4,d1
a1,b2,c4,d2
a2,b1,c1,d1
a2,b1,c1,d2
a2,b1,c2,d1
a2,b1,c2,d2
a2,b1,c3,d1
a2,b1,c3,d2
a2,b1,c4,d1
a2,b1,c4,d2
a2,b2,c1,d1
a2,b2,c1,d2
a2,b2,c2,d1
a2,b2,c2,d2
a2,b2,c3,d1
a2,b2,c3,d2
a2,b2,c4,d1
a2,b2,c4,d2
a3,b1,c1,d1
a3,b1,c1,d2
a3,b1,c2,d1
a3,b1,c2,d2
a3,b1,c3,d1
a3,b1,c3,d2
a3,b1,c4,d1
a3,b1,c4,d2
a3,b2,c1,d1
a3,b2,c1,d2
a3,b2,c2,d1
a3,b2,c2,d2
a3,b2,c3,d1
a3,b2,c3,d2
a3,b2,c4,d1
a3,b2,c4,d2
 
 
     
    