6

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
OMG Ponies
  • 325,700
  • 82
  • 523
  • 502
aadersh patel
  • 709
  • 3
  • 8
  • 9

1 Answers1

11

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
Jørn Schou-Rode
  • 37,718
  • 15
  • 88
  • 122