Web Wiz - Green Windows Web Hosting

  New Posts New Posts RSS Feed - Problem with select statement...
  FAQ FAQ  Forum Search   Events   Register Register  Login Login

Problem with select statement...

 Post Reply Post Reply
Author
drose0 View Drop Down
Newbie
Newbie
Avatar

Joined: 07 December 2003
Location: United States
Status: Offline
Points: 4
Post Options Post Options   Thanks (0) Thanks(0)   Quote drose0 Quote  Post ReplyReply Direct Link To This Post 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


Back to Top
Phat View Drop Down
Senior Member
Senior Member


Joined: 23 February 2003
Status: Offline
Points: 386
Post Options Post Options   Thanks (0) Thanks(0)   Quote Phat Quote  Post ReplyReply Direct Link To This Post 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.
Back to Top
pmormr View Drop Down
Senior Member
Senior Member


Joined: 06 January 2003
Location: United States
Status: Offline
Points: 1479
Post Options Post Options   Thanks (0) Thanks(0)   Quote pmormr Quote  Post ReplyReply Direct Link To This Post Posted: 07 December 2003 at 12:33pm
what's the dollar sign ($) do in SQL?
Back to Top
drose0 View Drop Down
Newbie
Newbie
Avatar

Joined: 07 December 2003
Location: United States
Status: Offline
Points: 4
Post Options Post Options   Thanks (0) Thanks(0)   Quote drose0 Quote  Post ReplyReply Direct Link To This Post Posted: 07 December 2003 at 7:07pm
Originally posted by pmormr 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.
Back to Top
fernan82 View Drop Down
Mod Builder Group
Mod Builder Group
Avatar

Joined: 17 November 2002
Location: United States
Status: Offline
Points: 362
Post Options Post Options   Thanks (0) Thanks(0)   Quote fernan82 Quote  Post ReplyReply Direct Link To This Post 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
Back to Top
drose0 View Drop Down
Newbie
Newbie
Avatar

Joined: 07 December 2003
Location: United States
Status: Offline
Points: 4
Post Options Post Options   Thanks (0) Thanks(0)   Quote drose0 Quote  Post ReplyReply Direct Link To This Post Posted: 08 December 2003 at 11:23pm
Originally posted by fernan82 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.     
Back to Top
fernan82 View Drop Down
Mod Builder Group
Mod Builder Group
Avatar

Joined: 17 November 2002
Location: United States
Status: Offline
Points: 362
Post Options Post Options   Thanks (0) Thanks(0)   Quote fernan82 Quote  Post ReplyReply Direct Link To This Post 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
Back to Top
drose0 View Drop Down
Newbie
Newbie
Avatar

Joined: 07 December 2003
Location: United States
Status: Offline
Points: 4
Post Options Post Options   Thanks (0) Thanks(0)   Quote drose0 Quote  Post ReplyReply Direct Link To This Post Posted: 09 December 2003 at 11:28am
Originally posted by fernan82 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
Back to Top
 Post Reply Post Reply

Forum Jump Forum Permissions View Drop Down

Forum Software by Web Wiz Forums® version 12.08
Copyright ©2001-2026 Web Wiz Ltd.


Become a Fan on Facebook Follow us on X Connect with us on LinkedIn Web Wiz Blogs
About Web Wiz | Contact Web Wiz | Terms & Conditions | Cookies | Privacy Notice

Web Wiz is the trading name of Web Wiz Ltd. Company registration No. 05977755. Registered in England and Wales.
Registered office: Web Wiz Ltd, Unit 18, The Glenmore Centre, Fancy Road, Poole, Dorset, BH12 4FB, UK.

Prices exclude VAT at 20% unless otherwise stated. VAT No. GB988999105 - $, € prices shown as a guideline only.

Copyright ©2001-2026 Web Wiz Ltd. All rights reserved.