Herrozerro
Herrozerro

Reputation: 1681

Aliasing a self join

I have been working with MySQL and I have a question on self joins.

When you self join, do you need to alias both tables? For example:

FROM customer c1, customer c2

Now I know this works, but it also seems to work with

FROM customer, customer c2

Is there any particular reason to alias both tables beyond readability? Is there something wrong with not aliasing one table?

Upvotes: 1

Views: 84

Answers (1)

Mureinik
Mureinik

Reputation: 311393

Functionally, there's no benefit in aliasing both tables. However, aliasing both of them removes potential points of confusion and makes the query more readable.

Upvotes: 1

Related Questions