View previous topic :: View next topic |
Author |
Message |
Xildjian
Joined: 08 Jan 2005 Posts: 100
|
Posted: Sat Jan 26, 2008 17:03 Post subject: sql query question... |
|
|
Wondering if someone could help with this type of query, can't seem to get the magic incantation.
This is for a serverstatus web page. I want to display:
PlayerName CharName Race SubRace Level
PlayerName lives in t1 and the others in t2. Each table has a PlayerID column. So I want to select the PlayerName based on this PlayerID which I want to select from t2 if IsOnline colum in t2 equals 1.
Make sense?
How can I setup a query so all the information I want to display is returned in a row for each character?
Any help would be appreciated.
Thanks! _________________ Member Shadow of Iniquity development team |
|
Back to top |
|
|
virusman
Joined: 30 Jan 2005 Posts: 1020 Location: Russia
|
Posted: Sat Jan 26, 2008 17:08 Post subject: |
|
|
SELECT * FROM t2
INNER JOIN t1 ON t1.PlayerID=t2.PlayerID
WHERE t2.IsOnline=1
For further information read the MySQL Documentation:
http://dev.mysql.com/doc/ |
|
Back to top |
|
|
Xildjian
Joined: 08 Jan 2005 Posts: 100
|
Posted: Sat Jan 26, 2008 19:37 Post subject: |
|
|
virusman wrote: | SELECT * FROM t2
INNER JOIN t1 ON t1.PlayerID=t2.PlayerID
WHERE t2.IsOnline=1
For further information read the MySQL Documentation:
http://dev.mysql.com/doc/ |
Thanks that helps, but not exactly the result I need. I want to do something like this:
(SELECT PlayerName FROM table_player
INNER JOIN table_character ON table_player.PlayerID=table_character.PlayerID
WHERE table_character.IsOnline=1) UNION (SELECT CharName, Race, SubRace, OverallLevel FROM table_character WHERE IsOnline=1);
But since the columns are not the same the above doesn't work testing in the Query browser. _________________ Member Shadow of Iniquity development team |
|
Back to top |
|
|
virusman
Joined: 30 Jan 2005 Posts: 1020 Location: Russia
|
Posted: Sat Jan 26, 2008 19:48 Post subject: |
|
|
Xildjian wrote: | Thanks that helps, but not exactly the result I need. I want to do something like this:
But since the columns are not the same the above doesn't work testing in the Query browser. | SELECT p.PlayerName, c.CharName, c.Race, c.SubRace, c.OverallLevel
FROM table_player AS p
INNER JOIN table_character AS c ON p.PlayerID=c.PlayerID
WHERE c.IsOnline=1 |
|
Back to top |
|
|
Xildjian
Joined: 08 Jan 2005 Posts: 100
|
Posted: Sat Jan 26, 2008 20:38 Post subject: |
|
|
virusman wrote: | Xildjian wrote: | Thanks that helps, but not exactly the result I need. I want to do something like this:
But since the columns are not the same the above doesn't work testing in the Query browser. | SELECT p.PlayerName, c.CharName, c.Race, c.SubRace, c.OverallLevel
FROM table_player AS p
INNER JOIN table_character AS c ON p.PlayerID=c.PlayerID
WHERE c.IsOnline=1 |
Sweet works like a charm!
Even learned a new command
Thanks! _________________ Member Shadow of Iniquity development team |
|
Back to top |
|
|
|