Victor Subervi wrote:
Hi;
I get the following error:

*SQL query:*

SELECT ID, Item
FROM products
JOIN categories ON categories.ID = products.Category
LIMIT 0 , 30;

 *MySQL said:*
 #1052 - Column 'ID' in field list is ambiguous

Please note the error is about ambiguity. "products" has an ID field and so
does "categories". If I run the statement taking out the "ID" from the
select, it runs. So, where is the ambiguity??

The ambiguity is that the select clause doesn't know which table you're referring to, since you're joining two of them that both have an 'ID' field. This will work:

SELECT products.ID, Item
FROM products
JOIN categories ON categories.ID = products.Category
LIMIT 0 , 30;

Mark

--
MySQL General Mailing List
For list archives: http://lists.mysql.com/mysql
To unsubscribe:    http://lists.mysql.com/mysql?unsub=arch...@jab.org

Reply via email to