Re: join condition against where with coalesce

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Sim Zacks <sim(at)compulab(dot)co(dot)il>
Cc: pgsql-general(at)postgresql(dot)org
Subject: Re: join condition against where with coalesce
Date: 2006-11-12 17:13:24
Message-ID: 26530.1163351604@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

Sim Zacks <sim(at)compulab(dot)co(dot)il> writes:
> Should there be any difference between:
> select * from table1 a left join table2 b on a.pk=b.fk and b.typeid=14
> and
> select * from table1 a left join table2 b on a.pk=b.fk
> where coalesce(b.typeid,14)=14

Quite a lot: every A row is guaranteed to appear in the output of the
first query, but not in the second. Consider for instance an A row that
only joins to b row(s) having typeid 13.

regards, tom lane

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Tom Lane 2006-11-12 17:21:37 Re: Why isn't it allowed to create an index in a schema other than public?
Previous Message Richard Broersma Jr 2006-11-12 16:59:35 Re: Why overlaps is not working