#1
  1. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jan 2004
    Location
    essex UK
    Posts
    192
    Rep Power
    11

    tables one to many only getting one to one


    SQL Version 3.23

    2 tables members and games

    query:
    PHP Code:
        $sql "INSERT INTO  wintera SELECT 

    games.membershipSeq,members.sortFlag,members.membershipID,
    members.firstName,members.lastName,members.handicapStart,

    games.gameSeq,games.gameDate,games.gameQuarter,games.gameMonth,

    games.numberStrokes,games.handiCap,games.gameScore,games.lateScore,

    games.whenUpdated FROM games,members 

    WHERE games.membershipSeq=members.membershipSeq AND

    games.gameQuarter ='
    $myquarter'  AND 

    games.disqualifiedGame='
    $dis'AND members.sortFlag ='$sortTest'ASC"
    3rd table wintera created as a temporary.

    This only loads results 1 member 1 game

    I need to load 1 member 12 games

    I am new to MySQL so all help appreciated.
    Last edited by byte me; January 21st, 2004 at 09:35 AM.
    I love perl
  2. #2
  3. SQL Consultant
    Devshed Supreme Being (6500+ posts)

    Join Date
    Feb 2003
    Location
    Toronto Canada
    Posts
    27,147
    Rep Power
    4274
    [consults crystal ball to see the data values in your tables...]

    aha! it's your gafloozle column, it's got bad data in it!



    okay, seriously, your join condition is probably wrong

    WHERE games.membershipSeq=members.membershipSeq

    should be

    WHERE games.membershipID=members.membershipID

    at least, that's what i'm guessing, going strictly by intuition based on the column names you've used
    rudy.ca | @rudydotca
    Buy my SitePoint book: Simply SQL

IMN logo majestic logo threadwatch logo seochat tools logo