Re: How get column-wise table info from an arbitrary query?

Поиск
Список
Период
Сортировка
От Raymond O'Donnell
Тема Re: How get column-wise table info from an arbitrary query?
Дата
Msg-id 50BE9F4E.4090704@iol.ie
обсуждение исходный текст
Ответ на How get column-wise table info from an arbitrary query?  (Kenneth Tilton <ktilton@mcna.net>)
Ответы Re: How get column-wise table info from an arbitrary query?
Список pgsql-general
On 05/12/2012 01:04, Kenneth Tilton wrote:
> I am porting from MySQL some code that has to take an arbitrary query
> involving joins and build up a dictionary (in an HLL talking to Postgres
> over a socket) where each column name will be the key. The catch is that
> there will be duplicate entries where two joined tables have the same
> column such as "id", so I have to get the source table for each column.
> Here is a sample query:
>
>    select * from providers p inner join provider_types pt on pt.id
> <http://pt.id> = p.provider_type_id;
>
> I actually figured out how to get the table OID which would suffice, but
> I am porting MySQL code that could get fully qualified column names
> including a table alias if that were used. We allow other code to look
> up values in the dictionary with the alias as a prefix as a convenience,
> eg. "p.id <http://p.id>" or "pt.id <http://pt.id>".

Maybe I'm misunderstanding, but why don't you just give the columns an
alias directly? -

   select p.id as p_id, pt.id as pt_id, ....

Ray.


--
Raymond O'Donnell :: Galway :: Ireland
rod@iol.ie


В списке pgsql-general по дате отправления:

Предыдущее
От: Kenneth Tilton
Дата:
Сообщение: How get column-wise table info from an arbitrary query?
Следующее
От: Raymond O'Donnell
Дата:
Сообщение: Re: How get column-wise table info from an arbitrary query?