Re: HELP with a Query

From: Martijn van Oosterhout <kleptog(at)svana(dot)org>
To: Alex <alex(at)meerkatsoft(dot)com>
Cc: pgsql-general(at)postgresql(dot)org
Subject: Re: HELP with a Query
Date: 2004-02-21 08:55:59
Message-ID: 20040221085559.GE28711@svana.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

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(at)svana(dot)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

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Henrik Farre 2004-02-21 12:18:45 Re: pg_dumpall dies
Previous Message Alex 2004-02-21 08:20:51 HELP with a Query