aadersh patel
aadersh patel

Reputation: 719

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

Upvotes: 6

Views: 7945

Answers (1)

Jørn Schou-Rode
Jørn Schou-Rode

Reputation: 38346

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

Upvotes: 11

Related Questions