Oracle FAQ | Your Portal to the Oracle Knowledge Grid |
![]() |
![]() |
Home -> Community -> Usenet -> c.d.o.misc -> Re: need help with sql
On Wed, 02 Mar 2005 21:09:44 GMT, "Starton X. Mangrove"
<desdfsdf_sdf393_at_yahoo.com> wrote:
>I have the following simple query that pulls information for a gui tree menu
>
>SELECT item_id, item_title, item_order, parent_id, shared_id
>FROM tree_menu
>ORDER BY item_order;
>
>I need to select the item_title in the normal way, except when shared_id is
>not zero. If its not zero it means shared_id holds the item_id of another
>item. If it's not zero then I need to get the item_title with id of
>shared_id.
>
>basically something like:
>SELECT item_id, (IF shared_id = 0 THEN item_title ELSE item_title of item
>with item_id = shared_id), item_order, parent_id, shared_id
>FROM tree_menu
>ORDER BY item_order;
>
>Oracle 9i
>
>Thanks in Advance
>
select x.item_id, decode(x.item_id,0,x.item_title, y.item_title)
item_title, x.item_order, x.parent_id, x.shared_id
from tree_menu x, tree_menu y
where y.item_id(+) = x.shared_id
order by x.item_order;
-- Sybrand Bakker, Senior Oracle DBAReceived on Wed Mar 02 2005 - 16:00:14 CST
![]() |
![]() |