Received: from localhost (postgresql.org [64.49.215.8]) by postgresql.org (Postfix) with ESMTP id 17248475E52 for ; Fri, 18 Oct 2002 14:57:54 -0400 (EDT) Received: from sam.on-net.net (sam.on-net.net [204.117.190.8]) by postgresql.org (Postfix) with ESMTP id 37EC4475921 for ; Fri, 18 Oct 2002 14:57:52 -0400 (EDT) Received: from edison (edison.base2inc.com [206.229.85.132]) by sam.on-net.net (8.11.3/8.11.6) with SMTP id g9IIsOq16527 for ; Fri, 18 Oct 2002 13:54:24 -0500 (EST) Message-ID: <027d01c276d8$504a1100$8455e5ce@edison> From: "Frank Morton" To: References: Subject: join question Date: Fri, 18 Oct 2002 13:58:13 -0500 MIME-Version: 1.0 Content-Type: multipart/alternative; boundary="----=_NextPart_000_027A_01C276AE.66A8C9C0" X-Priority: 3 X-MSMail-Priority: Normal X-Mailer: Microsoft Outlook Express 6.00.2600.0000 X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2600.0000 X-Virus-Scanned: by AMaViS new-20020517 X-Archive-Number: 200210/244 X-Sequence-Number: 9961 This is a multi-part message in MIME format. ------=_NextPart_000_027A_01C276AE.66A8C9C0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable For the SQL gurus, a query where I'm not getting the expected results. Trying to write it using sql compatible with both postgres and mysql. There are two tables: table =3D profile int id char name table =3D attribute int id int containerId char name char value Multiple attribute rows correspond to a single profile row where attribute.containerId =3D profile.id These two queries result in one row being returned, which is the expected result: select name from profile where ((profile.state=3D'1020811')); select profile.name from profile,attribute where (((attribute.name=3D'descr= iption') and (attribute.value=3D'1020704') and (profile.id=3Dattribute.cont= ainerId))); But, I thought this next query would just be a simple way to combine the two queries with an "or" operator, still returning one row, actually returns ALL rows of attribute: select profile.name from profile,attribute where ((profile.state=3D'1020811= ') or ((attribute.name=3D'marketsegment') and (attribute.value=3D'1020704')= and (profile.id=3Dattribute.containerId))); Why doesn't this last query return just one row? TIA ------=_NextPart_000_027A_01C276AE.66A8C9C0 Content-Type: text/html; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable
For the SQL gurus, a query where I'm not g= etting=20 the expected
results. Trying to write it using sql compatible with both postgres
and mysql.
 
There are two tables:
 
table =3D profile
int id
char name
 
table =3D attribute
int id
int containerId
char name
char value
 
Multiple attribute rows correspond to a si= ngle=20 profile row where
attribute.containerId =3D profile.id
 
These two queries result in one row being = returned,=20 which is
the expected result:
 
select name from profile where ((profile.state=3D'1020811'));

s= elect=20 profile.name from profile,attribute where (((attribute.name=3D'description'= ) and=20 (attribute.value=3D'1020704') and (profile.id=3Dattribute.containerId)));
But, I thought this next query would just = be a=20 simple way to combine the two
queries with an "or" operator, still retur= ning one=20 row, actually returns
ALL rows of attribute:
=
select profile.name from profile,attribute= where=20 ((profile.state=3D'1020811') or ((attribute.name=3D'marketsegment') and=20 (attribute.value=3D'1020704') and (profile.id=3Dattribute.containerId)));
 
Why doesn't this last query return just on= e=20 row?
 
TIA
 
------=_NextPart_000_027A_01C276AE.66A8C9C0--