From: John Fabiani <johnf@jfcomputer.com>
To: pgsql-sql@postgresql.org <pgsql-sql@postgresql.org>
Subject: using ordinal_position
Date: Thu, 07 Jun 2012 16:17:34 -0700
Message-ID: <4FD1368E.5000304@jfcomputer.com> (raw)
I'm attempting to retrieve data using a select statement without knowing
the column names. I know the ordinal position but not the name of the
column (happens to be a date::text and I have 13 fields).
Below provides the name of the column in position 3:
select column_name from (select column_name::text, ordinal_position from
information_schema.columns where
table_name='wk_test') as foo where ordinal_position = 3;
But how can I use the above as a column name in a normal select statement.
Unlike other databases I just can't use ordinal position in the select
statement - RIGHT???
Johnf
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients using the --to and --cc options:
reply via email
To: pgsql-sql@postgresql.org
Cc: johnf@jfcomputer.com
Subject: Re: using ordinal_position
In-Reply-To: <4FD1368E.5000304@jfcomputer.com>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox