Re: SELECT with WHERE clause by column number - Mailing list pgsql-sql

From Aaron Bono
Subject Re: SELECT with WHERE clause by column number
Date
Msg-id bf05e51c0612180936w11bd270an8d845cf4621a9d65@mail.gmail.com
Whole thread Raw
In response to SELECT with WHERE clause by column number  (Carlos Santos <carloscompels@yahoo.com.br>)
List pgsql-sql
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.com
   http://codeelixir.com
==================================================================

pgsql-sql by date:

Previous
From: Richard Huxton
Date:
Subject: Re: SELECT with WHERE clause by column number
Next
From: Carlos Santos
Date:
Subject: Res: SELECT with WHERE clause by column number