X-Original-To: pgsql-general-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.2]) by svr1.postgresql.org (Postfix) with ESMTP id A5EE2D1DF71 for ; Sat, 21 Feb 2004 08:56:03 +0000 (GMT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) with ESMTP id 08943-05 for ; Sat, 21 Feb 2004 04:56:00 -0400 (AST) Received: from svana.org (svana.org [203.20.62.76]) by svr1.postgresql.org (Postfix) with ESMTP id 46618D1D7FB for ; Sat, 21 Feb 2004 04:56:00 -0400 (AST) Received: from kleptog by svana.org with local (Exim 3.35 #1 (Debian)) id 1AuSvX-0001og-00; Sat, 21 Feb 2004 19:55:59 +1100 Date: Sat, 21 Feb 2004 19:55:59 +1100 From: Martijn van Oosterhout To: Alex Cc: pgsql-general@postgresql.org Subject: Re: HELP with a Query Message-ID: <20040221085559.GE28711@svana.org> Reply-To: Martijn van Oosterhout Mail-Followup-To: Alex , pgsql-general@postgresql.org References: <403714E3.2060600@meerkatsoft.com> Mime-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha1; protocol="application/pgp-signature"; boundary="EP0wieDxd4TSJjHq" Content-Disposition: inline In-Reply-To: <403714E3.2060600@meerkatsoft.com> User-Agent: Mutt/1.3.28i X-PGP-Key-ID: Length=1024; ID=0x0DC67BE6 X-PGP-Key-Fingerprint: 295F A899 A81A 156D B522 48A7 6394 F08A 0DC6 7BE6 X-PGP-Key-URL: X-Virus-Scanned: by amavisd-new at postgresql.org X-Archive-Number: 200402/996 X-Sequence-Number: 57707 --EP0wieDxd4TSJjHq Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable On Sat, Feb 21, 2004 at 05:20:51PM +0900, Alex wrote: > Hi, > I need some help with a query. > I use a reference table to lookup some codes. Everything works well if th= e=20 > reference table contains a reference but the query fails if no reference= =20 > fails (Z.ref_code=3D123456). What I need to is either return 0 or null in= to=20 > Z.prim_exch if no reference can be found. Whats the best way to do that ?= I=20 > tried a sub query but also did not succeed. Lookup an SQL site about OUTER JOINS. Should do what you want. --=20 Martijn van Oosterhout http://svana.org/kleptog/ > If the Catholic church can survive the printing press, science fiction > will certainly weather the advent of bookwarez. > http://craphound.com/ebooksneitherenorbooks.txt - Cory Doctorow --EP0wieDxd4TSJjHq Content-Type: application/pgp-signature Content-Disposition: inline -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.0.6 (GNU/Linux) Comment: For info see http://www.gnupg.org iD8DBQFANx0fY5Twig3Ge+YRAoC9AJ4+hyVNRYvizfXBFArV6wgt1xLbzwCdFEA+ GvioJ6yr3FttO0WYcQxsBsQ= =+N+C -----END PGP SIGNATURE----- --EP0wieDxd4TSJjHq--