Re: getting a query column to return 0 if nothing matches

From: Michael Fuhr <mike(at)fuhr(dot)org>
To: Dan Tenenbaum <dandante(at)gmail(dot)com>
Cc: pgsql-sql(at)postgresql(dot)org
Subject: Re: getting a query column to return 0 if nothing matches
Date: 2006-01-04 02:42:47
Message-ID: 20060104024246.GA10993@winnie.fuhr.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-sql

On Tue, Jan 03, 2006 at 02:15:25PM -0800, Dan Tenenbaum wrote:
> I want to show all rows where the first part of the WHERE clause is true,
> regardless of whether the provider_key is in the login_provider table (in
> that cause, I want to show 0 in that column).

Sounds like you're looking for an outer join.

http://www.postgresql.org/docs/8.1/interactive/tutorial-join.html
http://www.postgresql.org/docs/8.1/interactive/queries-table-expressions.html

--
Michael Fuhr

In response to

Browse pgsql-sql by date

  From Date Subject
Next Message Richard Huxton 2006-01-04 09:21:22 Re: Loading lots of data in a SQL command
Previous Message frank church 2006-01-04 01:32:11 Loading lots of data in a SQL command