Received: from relay-smtp2.sip.fr (mailhost.sip.fr [194.2.210.177]) by hub.org (8.9.3/8.9.3) with ESMTP id NAA49283 for ; Tue, 28 Dec 1999 13:28:34 -0500 (EST) (envelope-from Alain.Tesio@sip.fr) From: Alain.Tesio@sip.fr Received: from applications.sip.fr (applications.sip.fr [1.1.1.50]) by relay-smtp2.sip.fr (8.9.1a/jtpda-5.3.1) with SMTP id SAA25848 ; Tue, 28 Dec 1999 18:26:57 GMT Received: by applications.sip.fr(Lotus SMTP MTA v4.6.3 (778.2 1-4-1999)) id C1256855.0065928E ; Tue, 28 Dec 1999 19:29:26 +0100 X-Lotus-FromDomain: D_NOTES To: "M. Scott Smith" , pgsql-sql@postgreSQL.org Message-ID: Date: Tue, 28 Dec 1999 19:29:04 +0100 Subject: Re: [SQL] Problem with limit / union / etc. Mime-Version: 1.0 Content-type: text/plain; charset=us-ascii Content-Disposition: inline --- "M. Scott Smith" wrote: > select > event.title > from > event, event_url, url > where > date_start >= 'now'::date > and event.oid = event_url.eventid > and url.oid = event_url.urlid > > union > > select > event.title > from > event,event_url > where > date_start >= 'now'::date > and event.oid not in > (select distinct event_url.eventid from event_url) > > order by event.date_start asc limit $total; Maybe the limit is applied only on the second query. What about the following query ? Alain == select event.title,date_start into temp tmp_events from event, event_url, url where date_start >= 'now'::date and event.oid = event_url.eventid and url.oid = event_url.urlid limit $total; insert tmp_events select event.title,date_start from event,event_url where date_start >= 'now'::date and event.oid not in (select distinct event_url.eventid from event_url) limit $total; select title from tmp_events order by event.date_start asc limit $total; drop table tmp_events;