Put the lists into separate tables. Generate the cross join of the whole set of tables. *poof*
In reply to Use SQL by herveus in thread Combinatorics problem by perlrocks