Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Why does this SQL code give error 1066 (Not unique table/alias: 'customer')?

Why does the MySQL query below give error 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
like image 931
aadersh patel Avatar asked Mar 25 '10 22:03

aadersh patel


1 Answers

You have listed the table customer twice in your FROM statement. Here's the fixed version:

SELECT customer.id, customer.firstName, account.id
FROM account
INNER JOIN customer
ON customer.id = account.customerId
ORDER BY customer.id
like image 52
Jørn Schou-Rode Avatar answered Sep 24 '22 16:09

Jørn Schou-Rode