Re: select as

From: Michael Fuhr <mike(at)fuhr(dot)org>
To: Bambero <bambero(at)tlen(dot)pl>
Cc: pgsql-general(at)postgresql(dot)org
Subject: Re: select as
Date: 2004-12-23 18:20:29
Message-ID: 20041223182029.GA64609@winnie.fuhr.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

On Thu, Dec 23, 2004 at 06:37:14PM +0000, Bambero wrote:

> Is there any easy way to select all fields from table (*) but the result
> should looks like this:
>
> 1| 2| 3
> ----+-----+------
> asas| asd | dasd
> ada | ads | dasa
>
> Column name should be a number of column.

Why do you need to do this? Anyway, if you're making queries with
an interface that can fetch rows as an array, then you could display
column numbers based on their position in the array.

> I don't know what fields are in the table so:
>
> select fieldname as 1, fieldname2 as 2
>
> is useless.

What problem are you trying to solve? Why are you querying a table
when you don't know what fields it has? Are you building a generic
interface for querying any table? If so, then you can get column
positions and types by examining the system catalogs. See the
"System Catalogs" and "The Information Schema" chapters in the
PostgreSQL documentation (Information Schema is available in 7.4
and later).

--
Michael Fuhr
http://www.fuhr.org/~mfuhr/

In response to

  • select as at 2004-12-23 18:37:14 from Bambero

Browse pgsql-general by date

  From Date Subject
Next Message Bambero 2004-12-23 18:37:14 select as
Previous Message Lonni J Friedman 2004-12-23 18:03:12 Re: monitoring tools