Re: SELECT with WHERE clause by column number

Поиск
Список
Период
Сортировка
От Aaron Bono
Тема Re: SELECT with WHERE clause by column number
Дата
Msg-id bf05e51c0612180936w11bd270an8d845cf4621a9d65@mail.gmail.com
обсуждение исходный текст
Ответ на SELECT with WHERE clause by column number  (Carlos Santos <carloscompels@yahoo.com.br>)
Список 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 по дате отправления:

Предыдущее
От: Richard Huxton
Дата:
Сообщение: Re: SELECT with WHERE clause by column number
Следующее
От: Carlos Santos
Дата:
Сообщение: Res: SELECT with WHERE clause by column number