EchoFool Posted February 14, 2008 Share Posted February 14, 2008 I have two tables which have simple terms this: Item ID | User ID | Quantity 1 1 200 And the other has: Item ID | TradeAllowed | 1 1 With a query like this: $GetItems = mysql_query("SELECT useritem.ItemID,useritem.Quantity FROM useritem,item WHERE useritem.UserID='{$_SESSION['Current_User']}' AND useritem.Quantity > 0 AND item.Trade='1'") Or die(mysql_error()); But for some reason say the user has the item. and the item does exist in both tables which it should. When i echo mysql_num_rows($GetItems); it echo's 3. No idea where it gets 3 from. If anything 2 would make sense but it should only load one. Why does it display 3? Quote Link to comment Share on other sites More sharing options...
Barand Posted February 14, 2008 Share Posted February 14, 2008 Because you don't specify that the table should be joined on itemID, so it joins each record in one tablewith each record in the other. <?php $GetItems = mysql_query("SELECT useritem.ItemID,useritem.Quantity FROM useritem INNER JOIN item ON useritem.itemID = item.itemID WHERE useritem.UserID='{$_SESSION['Current_User']}' AND useritem.Quantity > 0 AND item.Trade='1'") or die(mysql_error()); ?> Quote Link to comment Share on other sites More sharing options...
EchoFool Posted February 15, 2008 Author Share Posted February 15, 2008 Oh i see you have to tell it where the link is. Ok thankyou! How do i topic solve? Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.