Results 1 to 2 of 2

Thread: Table to table ID joins

  1. #1

    Thread Starter
    Hyperactive Member tomcatexodus's Avatar
    Join Date
    Feb 2001
    Posts
    372

    Exclamation Table to table ID joins

    Hey all,

    I'm having a problem getting a query to return anything on the tables I have set up on my XAMPP running MySQL 5.1.11.

    The query I'm using to attempt to test this is:
    Code:
    SELECT * FROM card
    INNER JOIN cardgame1
    ON card.cardID = cardgame1.cardID
    INNER JOIN cardgame2
    ON card.cardID = cardgame2.cardID
    WHERE card.cardID=1;
    The card table holds basic information about cards like names, ID, who created them, etc., whereas the cardgame1, cardgame2, etc., tables hold more game specific values about the different games.

    cardgame1, 2, and so on, are config'd with a foreign key pointing back to card.

    Anyways, given a cardID, I'm trying to pull all the data from all the tables with that ID (since all the cardgames share IDs from the card table, only one table's results should have any values. this is fine, because I can parse that easily)

    Any ideas? should I revamp my table structure?

    thanks in advance

    EDIT:

    oh yea.. the problem is i'm getting 0 rows fetched.
    IWS

  2. #2
    A SQL Server fool GaryMazzone's Avatar
    Join Date
    Aug 2005
    Location
    Dover,NH
    Posts
    7,493

    Re: Table to table ID joins

    If the are not cards in one of the cardgame tables then there will be no results since you specified Inner Join for all the joins. Did you try Left or Right Outer joins? That would bring back card weither there is a match in all the tables or not
    Sometimes the Programmer
    Sometimes the DBA

    Mazz1

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width