Re: select where in and order

From: "Roger Hand" <rhand(at)ragingnet(dot)com>
To: "Tony Smith" <quickcur(at)yahoo(dot)com>, <pgsql-general(at)postgresql(dot)org>
Subject: Re: select where in and order
Date: 2006-03-10 02:43:25
Message-ID: DB28E9B548192448A4E8C8A3C1B1E475FC3311@sj1-exch-01.us.corp.kailea.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

Tony Smith wrote on
Thursday, March 09, 2006 6:33 PM
> To: pgsql-general(at)postgresql(dot)org
> Subject: [GENERAL] select where in and order
>
>
> I have two tables action and group:
>
> action
> ------------------------
> id,
> name
>
> group:
> ------------------------
> action_id
> rank
>
> I what to select from action table by order by the
> rank in the group table.
>
> If I use
>
> select * from action where id in (select action_id
> from group order by rank)

Try something like:

select a.*, g.action_id
FROM action a
INNER JOIN group g
ON a.id = g.action_id
ORDER BY g.action_id

Browse pgsql-general by date

  From Date Subject
Next Message Chris 2006-03-10 02:45:48 Re: select where in and order
Previous Message Tom Lane 2006-03-10 02:43:11 Re: Run PostgreSQL with Administrator account in Windows