Hi all!
For a match schedule I would like to find all possible combinations of
teams playing home and away (without teams playing to themselves of course).
I now the simple version works something like this:
For a (very) simple table containing three rows like this:
row 1: A
row 2: B
row 3: C
SELECT DISTINCT
t1.*, t2.* FROM t1, t1 as t2
WHERE
t1.id!=t2.id
ORDER BY
t1.id, t2.id;
would result in the following solution:
col1 col2
row1 A B
row2 A C
row3 B A
row4 B C
row5 C A
row6 C B
To find all the teams in a certain group I need to use the following query:
SELECT DISTINCT
team
FROM
program
WHERE
program.group = 'D2B'
AND (
id_season=IF(DA TE_FORMAT(CURRE NT_DATE(), '%m%d') >= '1101'
OR
DATE_FORMAT(CUR RENT_DATE(), '%m%d') < '0401' , 0, 4)
OR
id_season= IF(DATE_FORMAT( CURRENT_DATE(), '%m%d') >= '1101'
OR
DATE_FORMAT(CUR RENT_DATE(), '%m%d') < '0401' , 0,
IF(DATE_FORMAT( CURRENT_DATE(), '%m%d') > '0715', 1, 3))
);
As a relatively newbie on (my)SQL I am having trouble converting the
simple query stated above to a more extended one, that includes the last
query to find the teams in the group, for which I would like to find all
possible combinations of matches to be played.
I'm using MySQL 4.0.22 so I believe subqueries are not an option as I
can not upgrade to a newer version for the moment.
Can some one help me out? Thanks in advance!
Jonathan
--
A: Because it messes up the order in which people normally read text.
Q: Why is it such a bad thing?
A: Top-posting.
Q: What is the most annoying thing on usenet and in e-mail?
Comment