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

7.7k Views Asked by At

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
1

There are 1 best solutions below

1
On BEST ANSWER

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