| Author |
Topic Search Topic Options
|
drose0
Newbie
Joined: 07 December 2003
Location: United States
Status: Offline
Points: 4
|
Post Options
Thanks(0)
Quote Reply
Topic: Problem with select statement... Posted: 07 December 2003 at 3:28am |
|
Whenever I use my select statement I am getting too many results
back. Say I have 1 entry that fits the criteria, it shows it
fine. If I have 2 then it shows both of them twice...if I have 3
it shows all 3 of them 3 times each. Here is my statement
select p.*,o.*,d.* from offense o, defense d,playerinfo p where
o.gameid=$game and d.gameid=$game and p.playerno=o.playerno
|
 |
Phat
Senior Member
Joined: 23 February 2003
Status: Offline
Points: 386
|
Post Options
Thanks(0)
Quote Reply
Posted: 07 December 2003 at 5:32am |
|
You may need a group by clause. If it is access then use the query builder in access to make the query.
|
 |
pmormr
Senior Member
Joined: 06 January 2003
Location: United States
Status: Offline
Points: 1479
|
Post Options
Thanks(0)
Quote Reply
Posted: 07 December 2003 at 12:33pm |
|
what's the dollar sign ($) do in SQL?
|
|
|
 |
drose0
Newbie
Joined: 07 December 2003
Location: United States
Status: Offline
Points: 4
|
Post Options
Thanks(0)
Quote Reply
Posted: 07 December 2003 at 7:07pm |
pmormr wrote:
what's the dollar sign ($) do in SQL? |
I am actually writing it in PHP, so those are variables. I was
checking to see if I had some sort of problem in my SELECT clause.
|
 |
fernan82
Mod Builder Group
Joined: 17 November 2002
Location: United States
Status: Offline
Points: 362
|
Post Options
Thanks(0)
Quote Reply
Posted: 08 December 2003 at 10:48pm |
|
Try something like this:
SELECT offense.*,
defense.*, playerinfo.* FROM playerinfo INNER JOIN (offense INNER JOIN
defense ON offense.gameid = defense.gameid) ON offense.playerno =
playerinfo.playerno WHERE offense.gameid=$game;
I'm sure that should work on MS DATABASES, I'm not sure about MySQL if that's what you're using...
|
FeRnAN
|
 |
drose0
Newbie
Joined: 07 December 2003
Location: United States
Status: Offline
Points: 4
|
Post Options
Thanks(0)
Quote Reply
Posted: 08 December 2003 at 11:23pm |
fernan82 wrote:
Try something like this:
SELECT offense.*,
defense.*, playerinfo.* FROM playerinfo INNER JOIN (offense INNER JOIN
defense ON offense.gameid = defense.gameid) ON offense.playerno =
playerinfo.playerno WHERE offense.gameid=$game;
I'm sure that should work on MS DATABASES, I'm not sure about MySQL if that's what you're using...
|
That one didn't work initially, after slight modification it returned
the same results as what was happening before. Thanks for the
help though.
|
 |
fernan82
Mod Builder Group
Joined: 17 November 2002
Location: United States
Status: Offline
Points: 362
|
Post Options
Thanks(0)
Quote Reply
Posted: 08 December 2003 at 11:44pm |
|
That shouldn't return the same record more than once.... what database you're using.? also post some more code...
|
FeRnAN
|
 |
drose0
Newbie
Joined: 07 December 2003
Location: United States
Status: Offline
Points: 4
|
Post Options
Thanks(0)
Quote Reply
Posted: 09 December 2003 at 11:28am |
fernan82 wrote:
That shouldn't return the same record more than
once.... what database you're using.? also post some more code...
|
I am using MySQL. I fixed the problem, but it wasn't easy.
I had a ton of joining and stuff that was way over my head, but here is
what I eventually came up with that solved it.
select playerinfo.*,offense.*,defense.* from playerinfo join offense on
playerinfo.playerno=offense.playerno and offense.gameid=$game join
defense on offense.playerno = defense.playerno and defense.gameid=$game
|
 |