exists and is not null equivalence in query

From: Raphael Bauduin <rblists(at)gmail(dot)com>
To: pgsql-sql(at)postgresql(dot)org
Subject: exists and is not null equivalence in query
Date: 2009-05-28 12:36:31
Message-ID: f5227160905280536u4f131850pad984218b0fe8b5@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-sql

Hi,

In some code I am taking over, I found this query:

select count(t.trame_id) as count, v.voiture_num as voitureNum from
arch_trames t left join voiture v on (v.tag_id=t.tag_id)
where
(t.recept_time >= 1243509320691)
and exists (select v2.voiture_num from voiture v2 where v2.tag_id=v.tag_id)
group by v.voiture_num order by v.voiture_num

Am I right that I can replace the "and exists..." clause by
"and v.voiture_num is not null " in this case?

Thanks

Raphaël

--
Web database: http://www.myowndb.com
Free Software Developers Meeting: http://www.fosdem.org

Responses

Browse pgsql-sql by date

  From Date Subject
Next Message Tom Lane 2009-05-28 15:19:04 Re: exists and is not null equivalence in query
Previous Message Emi Lu 2009-05-26 15:48:25 Re: Allow column type to change without worrying about view dependencies