Re: [SQL] Problem with limit / union / etc.

Поиск
Список
Период
Сортировка
От Alain.Tesio@sip.fr
Тема Re: [SQL] Problem with limit / union / etc.
Дата
Msg-id C1256855.00659131.00@applications.sip.fr
обсуждение исходный текст
Список pgsql-sql


--- "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;





В списке pgsql-sql по дате отправления:

Предыдущее
От: "M. Scott Smith"
Дата:
Сообщение: Problem with limit / union / etc.
Следующее
От: Tom Lane
Дата:
Сообщение: Re: [SQL] Problem with limit / union / etc.