Received: from maia.hub.org (unknown [200.46.204.183]) by mail.postgresql.org (Postfix) with ESMTP id 7C70D6335B4 for ; Thu, 28 May 2009 09:37:05 -0300 (ADT) Received: from mail.postgresql.org ([200.46.204.86]) by maia.hub.org (mx1.hub.org [200.46.204.183]) (amavisd-maia, port 10024) with ESMTP id 86668-07 for ; Thu, 28 May 2009 09:36:58 -0300 (ADT) X-Greylist: domain auto-whitelisted by SQLgrey-1.7.6 Received: from mail-bw0-f163.google.com (mail-bw0-f163.google.com [209.85.218.163]) by mail.postgresql.org (Postfix) with ESMTP id 4A0A2632AD8 for ; Thu, 28 May 2009 09:36:34 -0300 (ADT) Received: by bwz7 with SMTP id 7so5623538bwz.19 for ; Thu, 28 May 2009 05:36:32 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:mime-version:received:date:message-id:subject :from:to:content-type:content-transfer-encoding; bh=z8ATHx7yi+osMpIGatC+l2LWH1uoGZQNOF3puCUI8Qg=; b=lA2WJxlhbP2XcXHrr0+uzFjkBLraft5cq8jrw1/t9BXAwI2p0GMw0rhOWFv/L/sX42 nne2afl33DtuuDk+NIDC2a/dy/vMYsjqYaUT6GUmwicM2v8CGAMGdGwX+VJKxMfSTfIA eUymOJRfiLmjjecgRNPigWGB7qG4IRfQdN7+0= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=mime-version:date:message-id:subject:from:to:content-type :content-transfer-encoding; b=ZXZgLpDOlwltd7sYicsOUmwNYOptzLTLm5Q+jVW9zCqCtxmJLVemocUde2lb1/KKZ5 eQ8/qcLBAbufmnCEV21obdg4BMg+vyyWoCmIqOhWSXdFaaaFEX57/8j4b61qLjUyzQnF QC116H82OD8MpowE4l26x0wzOtYexCsj5emwI= MIME-Version: 1.0 Received: by 10.204.69.143 with SMTP id z15mr1165450bki.29.1243514191661; Thu, 28 May 2009 05:36:31 -0700 (PDT) Date: Thu, 28 May 2009 14:36:31 +0200 Message-ID: Subject: exists and is not null equivalence in query From: Raphael Bauduin To: pgsql-sql@postgresql.org Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable X-Virus-Scanned: Maia Mailguard 1.0.1 X-Spam-Status: No, hits=0 tagged_above=0 required=5 tests=none X-Spam-Level: X-Archive-Number: 200905/112 X-Sequence-Number: 32604 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=3Dt.tag_id) where (t.recept_time >=3D 1243509320691) and exists (select v2.voiture_num from voiture v2 where v2.tag_id=3Dv.tag_i= d) 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=EBl --=20 Web database: http://www.myowndb.com Free Software Developers Meeting: http://www.fosdem.org