From: Aaron Bono <postgresql@aranya.com>
To: Carlos Santos <carlos@compels.net>
Cc: Lista PostgreSQL SQL <pgsql-sql@postgresql.org>
Subject: Re: SELECT with WHERE clause by column number
Date: Mon, 18 Dec 2006 11:36:07 -0600
Message-ID: <bf05e51c0612180936w11bd270an8d845cf4621a9d65@mail.gmail.com> (raw)
In-Reply-To: <20061218171739.98671.qmail@web57105.mail.re3.yahoo.com>
References: <20061218171739.98671.qmail@web57105.mail.re3.yahoo.com>
On 12/18/06, Carlos Santos <carloscompels@yahoo.com.br> wrote:
>
> Hi!
>
> I need to make a query like this:
>
> SELECT id FROM myTable WHERE column-number = 'value';
> (PS: The id column is the primary key of myTable).
>
> That is a select using column number in the WHERE clause what don't exists
> in SQL.
>
> I need this because there's a situation in my program where I don't have
> the column name.
> I've solved that querying Postgresql the name of the column with that
> number, and then creating the SELECT query.
> But this solution is slow... two database calls...
>
> Can I do this with a single query or in a faster way through SQL, an
> internal function or through a Procedural Language?
>
Can you provide the 2 queries you used to successfully do this in two
database calls?
I am not sure that select makes sense. Where clauses work on rows, not
columns. Having your two working queries will help us see what you are
really trying to do.
--
==================================================================
Aaron Bono
Aranya Software Technologies, Inc.
http://www.aranya.comhttp://codeelixir.com
==================================================================
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: postgresql@aranya.com, carlos@compels.net
Subject: Re: SELECT with WHERE clause by column number
In-Reply-To: <bf05e51c0612180936w11bd270an8d845cf4621a9d65@mail.gmail.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