Re: SELECT with WHERE clause by column number

From: "Aaron Bono" <postgresql(at)aranya(dot)com>
To: "Carlos Santos" <carlos(at)compels(dot)net>
Cc: "Lista PostgreSQL SQL" <pgsql-sql(at)postgresql(dot)org>
Subject: Re: SELECT with WHERE clause by column number
Date: 2006-12-18 17:36:07
Message-ID: bf05e51c0612180936w11bd270an8d845cf4621a9d65@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-sql

On 12/18/06, Carlos Santos <carloscompels(at)yahoo(dot)com(dot)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.com
http://codeelixir.com
==================================================================

In response to

Browse pgsql-sql by date

  From Date Subject
Next Message Carlos Santos 2006-12-18 18:36:49 Res: SELECT with WHERE clause by column number
Previous Message Richard Huxton 2006-12-18 17:25:27 Re: SELECT with WHERE clause by column number