Alias on an inner join

4110 views postgresql
0

I'm attempting to perform a LEFT JOIN on a table to consolidate some data, but I'd like to rename one of the fields I'm joining.

LEFT JOIN (SELECT email FROM user_email) AS foo ON (user_id = users.user_id)

I can select that data using foo.email, but I'd like to rename this field in the join so I can reference foo.user_email. What's the correct way to perform this?

answered question

1 Answer

12

LEFT JOIN (SELECT email as user_email FROM user_email) AS foo ON (user_id = users.user_id)

posted this

Have an answer?

JD

Please login first before posting an answer.