Search Postgresql Archives

Re: Trying to execute several queries involving temp tables in a PHP script

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Thank you Misa, the without-temp-tables query has worked flawlessly.


On Wed, Jun 13, 2012 at 5:01 PM, Misa Simic <misa.simic@xxxxxxxxx> 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;

-- 
Sent via pgsql-general mailing list (pgsql-general@xxxxxxxxxxxxxx)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-general



[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Index of Archives]     [Postgresql Jobs]     [Postgresql Admin]     [Postgresql Performance]     [Linux Clusters]     [PHP Home]     [PHP on Windows]     [Kernel Newbies]     [PHP Classes]     [PHP Books]     [PHP Databases]     [Postgresql & PHP]     [Yosemite]
  Powered by Linux