From: | Alexander Farber <alexander(dot)farber(at)gmail(dot)com> |
---|---|
To: | pgsql-general <pgsql-general(at)postgresql(dot)org> |
Subject: | Re: Trying to execute several queries involving temp tables in a PHP script |
Date: | 2012-06-15 14:41:44 |
Message-ID: | CAADeyWhZbtLCrFXqLzRBGnMX+VH8Pj1WAyKQw14EZHNNFaO1bg@mail.gmail.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-general |
Thank you Misa, the without-temp-tables query has worked flawlessly.
On Wed, Jun 13, 2012 at 5:01 PM, Misa Simic <misa(dot)simic(at)gmail(dot)com> wrote:
> I think you can have all in one query, without temp tables:
>
> SELECT r.rid, r.cards, to_char(r.stamp, 'DD.MM.YYYY
> HH24:MI') as day,
> c.bid, c.trix, c.pos, c.money, c.last_ip, c.quit,
> u.id, u.first_name, u.avatar, u.female, u.city,
> u.vip > CURRENT_DATE as vip
> FROM pref_rounds r, pref_cards c, pref_users u
> WHERE u.id = c.id and
> r.rid = c.rid and
> r.rid in (
>
> select rid
> from pref_cards
> where stamp > now() - interval '1 day' and
> id in (
> select id
> from pref_money
> where yw = to_char(current_timestamp - interval '1
> week', 'IYYY-IW')
> order by money
> desc limit 10
>
> ) and
> bid = 'Misere' and
> trix > 0
>
>
> )
> order by rid, pos;
From | Date | Subject | |
---|---|---|---|
Next Message | Philipp Kraus | 2012-06-15 15:18:25 | full text index / search |
Previous Message | Léa Massiot | 2012-06-15 13:25:50 | Starting a cluster as a service |