Re: How to alias table columns in result?

From: Mischa Sandberg <mischa(dot)sandberg(at)telus(dot)net>
To: pgsql-sql(at)postgresql(dot)org
Subject: Re: How to alias table columns in result?
Date: 2005-08-10 23:09:04
Message-ID: 1123715344.42fa89104f121@webmail.telus.net
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-sql

Quoting nori <kodmasin(at)gmail(dot)com>:

> Hi,
>
> If I have:
> 1.) table car with columns index and name
> 2.) table driver with columns index, name and car_index
>
> and query:
> SELECT d.*, c.* FROM driver as d LEFT OUTER JOIN car AS c ON
> d.car_index=c.index;
>
> How can I get results that have distinct names for columns (ex.
> d.name, d.index, c.name, c.index,...)?

Here's where you have to get explicit; d.* won't work.
If you want to have names with (.) in them, they have to be quoted, too.
Me, I'd use "d_name, d_index, c_name, ..."

SELECT d.name as "d.name",
d.index as "d.index",
c.name as "c.name",
...

In response to

Responses

Browse pgsql-sql by date

  From Date Subject
Next Message dario.mx 2005-08-11 00:42:01 Parentheses in FROM clause and evaluation order.
Previous Message nori 2005-08-10 22:45:24 How to alias table columns in result?