Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2000 Forums
 SQL Server Development (2000)
 Nested Query

Author  Topic 

takbar
Starting Member

2 Posts

Posted - 2005-03-10 : 16:20:09
Hi All,

Can somebody help me in building a stored procedure or a query which returns me a parent id for the following table:

Table2: proc_attach_xref

parent_id child_id
39402 39403
39403 39407
39407 39410
39410 39413
39411 39450
39450 39452
39450 39455


Here the idea is when i pass the child_id=39413 it should return me 39402 which is its parent_id. Similarlly if i pass input as 39455 it should return me 39411. I am using SYBASE database.

Thanks in advance. Please let me know if you need any further clarrifications,

Regards

X002548
Not Just a Number

15586 Posts

Posted - 2005-03-10 : 16:24:52
Well this is really a sql server site...but can you create functions and loop until you find no more rows

You can also try here

http://www.dbforums.com/f6



EDIT: You might also want to take a look here

http://www.sybase.com/support/manuals



Brett

8-)
Go to Top of Page

takbar
Starting Member

2 Posts

Posted - 2005-03-10 : 17:06:03
This links donot help me, anyways I am looking for the query if somebody can help me out.

Thanks,
Go to Top of Page
   

- Advertisement -