pg.ddx.io  pgsql-sql@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Alain.Tesio@sip.fr
To: M. Scott Smith <mssmit1@afterlife.ncsc.mil>
To: pgsql-sql@postgreSQL.org
Subject: Re: [SQL] Problem with limit / union / etc.
Date: Tue, 28 Dec 1999 19:29:04 +0100
Message-ID: <C1256855.00659131.00@applications.sip.fr> (raw)




--- "M. Scott Smith" <mssmit1@afterlife.ncsc.mil> 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;






view thread (3+ messages)  latest in thread

Message-ID: <C1256855.00659131.00@applications.sip.fr>
Permalink:  ../C1256855.00659131.00@applications.sip.fr/
Also on:    postgresql.org/message-id/C1256855.00659131.00@applications.sip.fr

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients from your mail client; the link fills in
  the headers below: reply via email
  Some clients, webmail especially, drop In-Reply-To and References from
  a link, and the reply then starts a new thread: use the mbox below.

  To: pgsql-sql@postgresql.org
  Cc: Alain.Tesio@sip.fr, mssmit1@afterlife.ncsc.mil
  Subject: Re: [SQL] Problem with limit / union / etc.
  In-Reply-To: <C1256855.00659131.00@applications.sip.fr>
  References: <C1256855.00659131.00@applications.sip.fr>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox