Received: from localhost (maia-4.hub.org [200.46.204.183]) by postgresql.org (Postfix) with ESMTP id 7BFC39F9357 for ; Mon, 18 Dec 2006 13:17:52 -0400 (AST) Received: from postgresql.org ([200.46.204.71]) by localhost (mx1.hub.org [200.46.204.183]) (amavisd-new, port 10024) with ESMTP id 14562-03 for ; Mon, 18 Dec 2006 13:17:40 -0400 (AST) X-Greylist: from auto-whitelisted by SQLgrey-1.7.4 Received: from web57105.mail.re3.yahoo.com (web57105.mail.re3.yahoo.com [216.252.111.118]) by postgresql.org (Postfix) with SMTP id 213C49FA222 for ; Mon, 18 Dec 2006 13:17:40 -0400 (AST) Received: (qmail 98673 invoked by uid 60001); 18 Dec 2006 17:17:39 -0000 DomainKey-Signature: a=rsa-sha1; q=dns; c=nofws; s=s1024; d=yahoo.com.br; h=Message-ID:Received:Date:From:Reply-To:Subject:To:MIME-Version:Content-Type; b=OQh+VMjxqx8HbFGbH5H5oL0lJvAIMUQnBL9bRHcVXWVdIJfu1aTKfnBnsFAir5vNsQMxj1gZlLgx/ZhIJggTMdJZP0pi1Cm4WgtsJY56WAlyuiD5zBr0NHS8VIFIy2968/JXLkxqgczM4EMFo44Ali5Tnyku8Ct7YFGQZJtqg9Y= ; Message-ID: <20061218171739.98671.qmail@web57105.mail.re3.yahoo.com> Received: from [201.58.182.50] by web57105.mail.re3.yahoo.com via HTTP; Mon, 18 Dec 2006 09:17:39 PST Date: Mon, 18 Dec 2006 09:17:39 -0800 (PST) From: Carlos Santos Reply-To: Carlos Santos Subject: SELECT with WHERE clause by column number To: Lista PostgreSQL SQL MIME-Version: 1.0 Content-Type: multipart/alternative; boundary="0-1843394556-1166462259=:98637" X-Virus-Scanned: Maia Mailguard 1.0.1 X-Archive-Number: 200612/128 X-Sequence-Number: 27084 --0-1843394556-1166462259=:98637 Content-Type: text/plain; charset=iso-8859-1 Content-Transfer-Encoding: quoted-printable Hi!=0A=0AI need to make a query like this:=0A=0ASELECT id FROM myTable WHER= E column-number =3D 'value';=0A(PS: The id column is the primary key of myT= able).=0A=0AThat is a select using column number in the WHERE clause what d= on't exists in SQL.=0A=0AI need this because there's a situation in my prog= ram where I don't have the column name.=0AI've solved that querying Postgre= sql the name of the column with that number, and then creating the SELECT = query.=0ABut this solution is slow... two database calls...=0A=0ACan I do t= his with a single query or in a faster way through SQL, an internal functi= on or through a Procedural Language?=0A=0AThanks =0A =0A Carlos Henrique Ia= zzetti Santos =0A=0ACompels Inform=E1tica =0A Santa Rita do Sapuca=ED - MG= =0ABRAZIL=0Awww.compels.net=0A=0A=0A=0A=0A=0A=0A=09=0A=0A=0A=0A=0A=09=0A=09= =09=0A_______________________________________________________ =0AVoc=EA que= r respostas para suas perguntas? Ou voc=EA sabe muito e quer compartilhar s= eu conhecimento? Experimente o Yahoo! Respostas !=0Ahttp://br.answers.yahoo= .com/ --0-1843394556-1166462259=:98637 Content-Type: text/html; charset=iso-8859-1 Content-Transfer-Encoding: quoted-printable
Hi!

I need to make a query like this:

SELECT id= FROM myTable WHERE column-number =3D 'value';
(PS: The id column is the primary key of myTable).

That is a select using column number in the WHERE clau= se 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 Procedur= al Language?

Thanks

Carlos Henrique Iazzetti Santos
Compel= s Inform=E1tica
Santa Rita do Sapuca=ED - MG
BRAZIL
www.compels.net

=0A=09=09
=0AYahoo! Acesso Gr=E1tis - In= ternet r=E1pida e gr=E1tis. Instale o discador agora! =0A --0-1843394556-1166462259=:98637--