Problem with select statement...
Printed From: Web Wiz Forums
Category: General Discussion
Forum Name: Database Discussion
Forum Description: Discussion and chat on database related topics.
URL: https://forums.webwiz.net/forum_posts.asp?TID=7916
Printed Date: 30 March 2026 at 7:27am Software Version: Web Wiz Forums 12.08 - https://www.webwizforums.com
Topic: Problem with select statement...
Posted By: drose0
Subject: Problem with select statement...
Date 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
|
Replies:
Posted By: Phat
Date 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.
|
Posted By: pmormr
Date Posted: 07 December 2003 at 12:33pm
what's the dollar sign ($) do in SQL?
------------- Paul A Morgan
http://www.pmorganphoto.com/" rel="nofollow - http://www.pmorganphoto.com/
|
Posted By: drose0
Date 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.
|
Posted By: fernan82
Date 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
http://www.danasoft.com/">
|
Posted By: drose0
Date 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.
|
Posted By: fernan82
Date 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
http://www.danasoft.com/">
|
Posted By: drose0
Date 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
|
|