Page 1 of 1

Mysql not quite working

Posted: Mon Mar 03, 2008 4:33 pm
by Snobbery08
I have used an inner join on 2 tables on ItemID but for some unknown reason its getting the wrong row lol!!

Not sure why from the logic i have placed in, it cannot be possible but im sure i've done some silly mistake in the query that i have not spotted so maybe some one here can:

Code: Select all

$Get = mysql_query("SELECT useritem.ItemID,useritem.Quantity FROM useritem 
            INNER JOIN item ON item.ItemID WHERE item.Trade=1 AND
                    useritem.UserID='{$_SESSION['Current_User']}' 
                    AND useritem.Quantity>0")
                        Or die(mysql_error());
I'll show ya the table layout i have with 2 items in ... one is the incorrect one which i will put in bold and the other is the one that this query is meant to grab. But sadly it grabs the one in red. The reason the red one is incorrect is because Trade is = 0 which is the only difference in my database. So i don't know why it's collecting that itemID of the red row instead of the black...

Useritem table:
ItemId | Quantity | UserID |
---1--- |-----5-----|----1-----|
---2---|-----1-----|----1-----|

Item table
ItemID | Trade |
---2---|-----0-----|
---1---|-----1-----|