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
https://forums.phpfreaks.com/topic/103648-help-with-error/
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
https://forums.phpfreaks.com/topic/103648-help-with-error/#findComment-530766
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.