Received: from localhost (unknown [200.46.208.211]) by mail.postgresql.org (Postfix) with ESMTP id ADBC56347C6 for ; Sat, 26 Sep 2009 16:54:02 -0300 (ADT) Received: from mail.postgresql.org ([200.46.204.86]) by localhost (mx1.hub.org [200.46.208.211]) (amavisd-maia, port 10024) with ESMTP id 11074-07 for ; Sat, 26 Sep 2009 19:53:48 +0000 (UTC) X-Greylist: from auto-whitelisted by SQLgrey-1.7.6 Received: from karnak.local (cpc3-lutn10-2-0-cust261.9-3.cable.virginmedia.com [81.97.85.6]) by mail.postgresql.org (Postfix) with ESMTP id 0A104634754 for ; Sat, 26 Sep 2009 16:53:51 -0300 (ADT) Received: from dwnoon.ntlworld.com (localhost [127.0.0.1]) by karnak.local (Postfix) with ESMTP id DB1911F002 for ; Sat, 26 Sep 2009 20:53:49 +0100 (BST) Date: Sat, 26 Sep 2009 20:53:49 +0100 From: David W Noon To: pgsql-sql@postgresql.org Subject: Re: simple (?) join Message-ID: <20090926205349.5fa284f1@dwnoon.ntlworld.com> In-Reply-To: <4ABE6360.20205@emproshunts.com> References: <200909241616.36933.gary.stainburn@ringways.co.uk> <20090924194629.44bc236f@dwnoon.ntlworld.com> <4ABBD34B.9080600@emproshunts.com> <20090924222106.23a5c1f3@dwnoon.ntlworld.com> <4ABE6360.20205@emproshunts.com> X-Mailer: Claws Mail 3.7.2 (GTK+ 2.16.6; i686-pc-linux-gnu) Mime-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit X-Virus-Scanned: Maia Mailguard 1.0.1 X-Spam-Status: No, hits=-1.57 tagged_above=-10 required=5 tests=AWL=-0.929, BAYES_20=-0.74, RDNS_DYNAMIC=0.1 X-Spam-Level: X-Archive-Number: 200909/127 X-Sequence-Number: 33192 On Sat, 26 Sep 2009 14:54:24 -0400, justin wrote about Re: [SQL] simple (?) join: [snip] >Quoting Gary >"How can I select all from orders and the last (latest) entry from the >orders_log?" In that case, a simple Cartesian product will do: SELECT o.*, maxi.ts FROM orders AS o, (SELECT MAX(ol_timestamp) AS ts FROM orders_log) AS maxi; Since the cardinality of the subquery "maxi" is 1, it will give a result set with cardinality of the complete orders table. I don't understand why anybody would want to do that. [De gustibus ... ] -- Regards, Dave [RLU #314465] ======================================================================= david.w.noon@ntlworld.com (David W Noon) =======================================================================