|
-
Nov 18th, 2009, 06:13 PM
#1
Thread Starter
Hyperactive Member
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.
-
Nov 18th, 2009, 06:39 PM
#2
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
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|