Search Postgresql Archives

Re: select where in and order

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

 



Tony Smith wrote on 
Thursday, March 09, 2006 6:33 PM
> To: pgsql-general@xxxxxxxxxxxxxx
> 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


[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