pg.ddx.io  pgsql-general@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Martijn van Oosterhout <kleptog@svana.org>
To: Alex <alex@meerkatsoft.com>
Cc: pgsql-general@postgresql.org
Subject: Re: HELP with a Query
Date: Sat, 21 Feb 2004 19:55:59 +1100
Message-ID: <20040221085559.GE28711@svana.org> (raw)
In-Reply-To: <403714E3.2060600@meerkatsoft.com>
References: <403714E3.2060600@meerkatsoft.com>

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 the 
> reference table contains a reference but the query fails if no reference 
> fails (Z.ref_code=123456). What I need to is either return 0 or null into 
> Z.prim_exch if no reference can be found. Whats the best way to do that ? I 
> tried a sub query but also did not succeed.

Lookup an SQL site about OUTER JOINS. Should do what you want.

-- 
Martijn van Oosterhout   <kleptog@svana.org>   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

view thread (16+ messages)  latest in thread

Message-ID: <20040221085559.GE28711@svana.org>
Permalink:  ../20040221085559.GE28711@svana.org/
Also on:    postgresql.org/message-id/20040221085559.GE28711@svana.org

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients from your mail client; the link fills in
  the headers below: reply via email
  Some clients, webmail especially, drop In-Reply-To and References from
  a link, and the reply then starts a new thread: use the mbox below.

  To: pgsql-general@postgresql.org
  Cc: kleptog@svana.org, alex@meerkatsoft.com
  Subject: Re: HELP with a Query
  In-Reply-To: <20040221085559.GE28711@svana.org>
  References: <403714E3.2060600@meerkatsoft.com> <20040221085559.GE28711@svana.org>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox