Doing multiple joins on one table
- From: "Yaniv Danan" <yaniv@xxxxxxxx>
- Date: Sat, 2 Sep 2006 22:26:02 +0200
I have those Tables:
CREATE TABLE GameYellows(
id INT NOT NULL AUTO_INCREMENT,
AddedDate DATETIME NOT NULL,
Player_ID INT NOT NULL,
)
CREATE TABLE GameReds(
id INT NOT NULL AUTO_INCREMENT,
AddedDate DATETIME NOT NULL,
Player_ID INT NOT NULL,
)
CREATE TABLE GameSubstitutes(
id INT NOT NULL AUTO_INCREMENT,
OutPlayer_ID INT NOT NULL,
InPlayer_ID INT NOT NULL,
)
CREATE TABLE Players(
id INT NOT NULL AUTO_INCREMENT,
FullName VARCHAR(250) NOT NULL,
)
What i need is actually to get a table of statistics for each player in the
players table.
meaning i need to return a table like this:
id | yellows | reds | substitutes_out | substitutes_in
---------------------------------------------------------------------
1 | 2 | 1 | 5 | 2
2 | 4 | 0 | 0 | 3
3 | 1 | 2 | 0 | 7
please help me solve this one, having hard time using join.
thanks, Yaniv.
.
- Follow-Ups:
- Re: Doing multiple joins on one table
- From: Arnie Rowland
- Re: Doing multiple joins on one table
- From: Hugo Kornelis
- Re: Doing multiple joins on one table
- Next by Date: Re: Doing multiple joins on one table
- Next by thread: Re: Doing multiple joins on one table
- Index(es):
Relevant Pages
|
Loading