Hi guys I'm having a bit of trouble with this one..
I need to generate all possible outcomes of a dynamically loaded database like this one..
COLOUR SIZE FABRIC
blue small denim
red medium cotton
green large wool
ok.. so for example this database (above) gets set up by the user the rows and columns can be added so I don't know how many rows/columns I'm dealing with.
If it was just 3 columns by x amoun开发者_如何学Ct of rows I could just set up a for loop i.e. keep adding x until it goes though all rows, then increment y until that goes though all columns, then increment z etc...
But being as I don't know how many rows are in the database I can't find a way of referencing the array..
I hope I've explained myself well enough for you to understand, I'm pretty new to programming and I've been trying to figure this one out for hours.
JOIN = Cartesian product
select * from
(select distinct colour from TBL) as t1 join
(select distinct size from TBL) as t2 join
(select distinct fabric from TBL) as t3
order by colour, size, fabric;
精彩评论