Received: from localhost (maia-4.hub.org [200.46.204.183]) by postgresql.org (Postfix) with ESMTP id 672069F9F46 for ; Mon, 18 Dec 2006 14:36:58 -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 43032-05 for ; Mon, 18 Dec 2006 14:36:50 -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 6234A9F9EED for ; Mon, 18 Dec 2006 14:36:50 -0400 (AST) Received: (qmail 23060 invoked by uid 60001); 18 Dec 2006 18:36:49 -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:Cc:MIME-Version:Content-Type; b=AA+Vkr6Psf8jQOIm70L82Z3zG/DzbiYQ7oTbM0QXRMQoNy2umf7mX2l3h/Yqx8keLjRJNdiuGFjbzrOEUVj+nCdXASVHR2EqwTNEW0kVrTSEFCREmKY7Syb0W2U2dWBtpgT6ndv2a44r4OFwxyl9RZ0cx4w5Iaf30RPnOX39v0E= ; Message-ID: <20061218183649.23058.qmail@web57105.mail.re3.yahoo.com> Received: from [201.58.182.50] by web57105.mail.re3.yahoo.com via HTTP; Mon, 18 Dec 2006 10:36:49 PST Date: Mon, 18 Dec 2006 10:36:49 -0800 (PST) From: Carlos Santos Reply-To: Carlos Santos Subject: Res: SELECT with WHERE clause by column number To: Richard Huxton Cc: Lista PostgreSQL SQL MIME-Version: 1.0 Content-Type: multipart/alternative; boundary="0-74035001-1166467009=:22657" X-Virus-Scanned: Maia Mailguard 1.0.1 X-Archive-Number: 200612/131 X-Sequence-Number: 27087 --0-74035001-1166467009=:22657 Content-Type: text/plain; charset=iso-8859-1 Content-Transfer-Encoding: quoted-printable All my columns have the same data type: text.=0ASo it's much easier.=0A =0A= Carlos Henrique Iazzetti Santos =0ACompels Inform=E1tica =0A Santa Rita do = Sapuca=ED - MG=0Awww.compels.net=0A=0A=0A----- Mensagem original ----=0ADe:= Richard Huxton =0APara: Carlos Santos =0ACc: Lista PostgreSQL SQL =0AEnviadas: Segund= a-feira, 18 de Dezembro de 2006 15:25:27=0AAssunto: Re: [SQL] SELECT with W= HERE clause by column number=0A=0ACarlos Santos wrote:=0A> SELECT id FROM m= yTable WHERE column-number =3D 'value';=0A> (PS: The id column is the prima= ry key of myTable).=0A> =0A> That is a select using column number in the WH= ERE clause what don't exists in SQL.=0A> =0A> I need this because there's a= situation in my program where I don't have the column name.=0A> I've solve= d that querying Postgresql the name of the column with that number, and the= n creating the SELECT query.=0A> But this solution is slow... two database= calls...=0A=0AIf you don't know what the column is, how do you know what y= ou are =0Atesting against? Or what type it is, for that matter?=0A=0AAnyway= , just have build a list of column-name,column-type pairs for =0Arelevant t= ables at application start-up, or store it in a configuration =0Afile. Unle= ss you're building/changing tables all the time, that should work.=0A=0AI'm= curious as to what type of application can usefuly query a database =0Awit= hout knowing what structure it has.=0A=0A-- =0A Richard Huxton=0A Archo= net Ltd=0A=0A---------------------------(end of broadcast)-----------------= ----------=0ATIP 4: Have you searched our list archives?=0A=0A = http://archives.postgresql.org=0A=0A=0A=0A=0A=0A=0A=0A=09=09=0A__________= _____________________________________________ =0AYahoo! Acesso Gr=E1tis - I= nternet r=E1pida e gr=E1tis. Instale =0Ao discador agora! =0Ahttp://br.aces= so.yahoo.com --0-74035001-1166467009=:22657 Content-Type: text/html; charset=iso-8859-1 Content-Transfer-Encoding: quoted-printable
All my columns have the same data type: text.
So it's mu= ch easier.
 
Carl= os Henrique Iazzetti Santos
Compels Inform=E1tica
Sant= a Rita do Sapuca=ED - MG
www.compels.net


----- Mensagem original ----
De: Richard Huxton <dev@archonet.com>= ;
Para: Carlos Santos <carlos@compels.net>
Cc: Lista PostgreSQL= SQL <pgsql-sql@postgresql.org>
Enviadas: Segunda-feira, 18 de Dezembr= o de 2006 15:25:27
Assunto: Re: [SQL] SELECT with WHERE clause by column= number

Carlos Santos wrote:
> SELECT id FROM myTable WHE= RE column-number =3D '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.
&= gt; I've solved that querying Postgresql the name of the column with that n= umber, and then creating  the SELECT query.
> But this solu= tion is slow... two database calls...

If you don't know what the col= umn is, how do you know what you are
testing against? Or what type it i= s, for that matter?

Anyway, just have build a list of column-name,co= lumn-type pairs for
relevant tables at application start-up, or store i= t in a configuration
file. Unless you're building/changing tables all the tim= e, that should work.

I'm curious as to what type of application can = usefuly query a database
without knowing what structure it has.

= --
   Richard Huxton
   Archonet Ltd

----= -----------------------(end of broadcast)---------------------------
TIP= 4: Have you searched our list archives?

    &nb= sp;          http://archives.postgresql.org<= /a>


=0A=09=09
=0AVoc=EA que= r respostas para suas perguntas? Ou voc=EA sabe muito e quer compartilhar s= eu conhecimento? Experimente o
Yahoo! Respostas! --0-74035001-1166467009=:22657--