I only take 1 column and the column’s name is “id”.
the records/values I get from the SELECT QUERY are:
1(id=1)
2(id=2)
3(id=3)
4(id=4)
From these 4 records I also want to get the triads and couples…
It’s for a soccer bet application, where someone selects lets say 4 games and wants to bet on all triads(4 of them).
ah yes. for testing purposes, table name in my example is amaze_games:
/* gets first result set */
SELECT a.id,
b.id,
c.id
FROM amaze_games a
INNER JOIN amaze_games b
ON a.id != b.id
AND a.id < b.id
INNER JOIN amaze_games c
ON b.id != c.id
AND b.id < c.id
/* gets second result set */
SELECT a.id,
b.id
FROM amaze_games a
INNER JOIN amaze_games b
ON a.id != b.id
AND a.id < b.id
that depends on what language your site is written in. i don’t know how to do it in CF.
hmm. i’m not sure how to approach using just SQL. not sure if it’s possible. it might be faster though to bring a [font=monospace]SELECT DISTINCT id FROM amaze_games[/font] into an array in your server-side language, then create the permutations there.