Received: from sss.pgh.pa.us (unknown [192.204.191.242]) by postgresql.org (Postfix) with ESMTP id 115CD476009 for ; Sat, 2 Mar 2002 18:22:50 -0500 (EST) Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) by sss.pgh.pa.us (8.11.4/8.11.4) with ESMTP id g22NMZS17343; Sat, 2 Mar 2002 18:22:35 -0500 (EST) To: dan@langille.org Cc: pgsql-sql@postgresql.org Subject: Re: using LIMIT only on primary table In-reply-to: <200203022235.g22MZYk55756@lists.unixathome.org> References: <200203022235.g22MZYk55756@lists.unixathome.org> Comments: In-reply-to "Dan Langille" message dated "Sat, 02 Mar 2002 17:35:31 -0500" Date: Sat, 02 Mar 2002 18:22:35 -0500 Message-ID: <17340.1015111355@sss.pgh.pa.us> From: Tom Lane X-Archive-Number: 200203/20 X-Sequence-Number: 6902 "Dan Langille" writes: > If I want all the items on the last 100 orders, I'd start like this: > SELECT * > from orders, order_items > where order_items.order_id = orders.id > LIMIT 100 I think you want SELECT * from (SELECT * from orders order by ID DESC limit 100) as recent_orders, order_items where order_items.order_id = recent_orders.id regards, tom lane