Debt Consolidation - Submit articles - Kamala - Wordpress Themes - Debt Consolidation

PDA

View Full Version : Query records' combinations


curlito
Oct 16th 2006, 6:43 am
What I need to do is to get all the combinations of the records from a query.

Let's say that my query gives me the records: 1,2,3,4

I need to also get these:

1,2,3
1,2,4
1,3,4
2,3,4

AND

1,2
1,3
1,4
2,3
2,4
3,4

This is for a betting application and when the player chooses 4 games or more I need to calculate the odds for the combinations of 3 matches and 2 matches...

I hope that's clear enough.

Thanks all in advance. :)

websiteideas
Oct 16th 2006, 2:47 pm
Can you show us the exact sql query you're using?

curlito
Oct 18th 2006, 12:52 am
it's just a SELECT query:

SELECT id
FROM myTable
WHERE id <= x;

and the results are:
1
2
3
4
.
.
x

and what i need is the combinations of (x-1), (x-2), ..., 2

Is that more clear?? :confused: