为什么这个SQL代码会给出错误1066(不唯一的表/别名:'customer')?

时间:2010-03-25 22:17:44

标签: mysql inner-join mysql-error-1066

为什么下面的MySQL查询会给出错误1066 (Not unique table/alias: 'customer')

SELECT customer.id, customer.firstName, account.id
FROM customer, account
INNER JOIN customer
ON customer.id = account.customerId 
ORDER BY customer.id

1 个答案:

答案 0 :(得分:8)

您已在customer声明中列出了FROM 两次表格。这是固定版本:

SELECT customer.id, customer.firstName, account.id
FROM account
INNER JOIN customer
ON customer.id = account.customerId
ORDER BY customer.id