Jump to content

Help with error..


EchoFool

Recommended Posts

I keep getting an error stating :

 

Not unique table/alias: 'useritem'

 

Not sure what I did wrong but I have narrowed it down to this query causing it, not sure where I went wrong though..

 

 

<?php
$Get = mysql_query("SELECT useritem.Quantity,item.Size FROM useritem,item INNER JOIN useritem ON item.ItemID = useritem.ItemID
	WHERE useritem.UserID='{$_SESSION['Current_User']}' AND useritem.`Where`='1'")
		Or die(mysql_error());
?>

 

Hope you can help me out here  ???

Link to comment
Share on other sites

You don't need 'useritem' in the table list when you specify an inner join...

 

SELECT useritem.Quantity, item.Size 
FROM item 
  INNER JOIN useritem ON item.ItemID = useritem.ItemID
WHERE useritem.UserID='" . $_SESSION['Current_User'] . "' AND useritem.`Where`='1'

 

Also, using reserved words for column names is a really bad idea...it just makes life more difficult in the long run. 

 

Is useritem.where a numeric datatype (int, mediumint, smallint, etc), or is it a character type?  If it's the latter, and it only contains numbers, change it.  If it's the former, then you don't have to put the 1 in your query in quotes...MySQL only does a type conversion on it (it sees it as string because of the quotes and then converts it to match the column type), which is an extra, unnecessary operation.

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.