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
 General SQL Server Forums
 New to SQL Server Programming
 Joining Back into table

Author  Topic 

masond
Constraint Violating Yak Guru

447 Posts

Posted - 2013-06-14 : 08:33:27
Hey Guys

Sorry to bother you with such a dump question
Aim- i need to the get account_Id of the parentsfid
The account_id is based on the #Update.FDMSAccountNo,

Parentsfid is the same as the #Update.FDMSAccountNo,

i would like to produce a new column called “ Parentaccount_Id

This is my table
Select
#Address.FDMSAccountNo,
Parentsfid,
#Update.FDMSAccountNo,
#Update.account_id
from #Address
inner join #Update on #Address.FDMSAccountNo = #Update.FDMSAccountNo

bandi
Master Smack Fu Yak Hacker

2242 Posts

Posted - 2013-06-14 : 09:36:23
what is the problem here?

--
Chandu
Go to Top of Page

masond
Constraint Violating Yak Guru

447 Posts

Posted - 2013-06-14 : 10:36:55
HI bandi

Okay every Fdmsaccountno has a unique account_id ,

Every Fdmsaccountno has a parentfid, every parentfid also has an account_id

i need to loop back into the table join Parentfid onto fdmsaccountno so i can get the parentfid account_id

Hope that makes sense
Go to Top of Page

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2013-06-14 : 10:52:23
sounds like this to me

if not post some data

Select
#Address.FDMSAccountNo,
Parentsfid,
u.FDMSAccountNo,
u.account_id,
u1.account_id as parentid
from #Address
inner join #Update u on #Address.FDMSAccountNo = u.FDMSAccountNo
inner join #Update u1 on u.parentfid = u1.fdmsaccountno


------------------------------------------------------------------------------------------------------
SQL Server MVP
http://visakhm.blogspot.com/
https://www.facebook.com/VmBlogs
Go to Top of Page

masond
Constraint Violating Yak Guru

447 Posts

Posted - 2013-06-14 : 11:06:26
Thats exactly what i need

thank you very much :)

You guys are a saviour :)
Go to Top of Page

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2013-06-14 : 14:53:21
welcome

------------------------------------------------------------------------------------------------------
SQL Server MVP
http://visakhm.blogspot.com/
https://www.facebook.com/VmBlogs
Go to Top of Page
   

- Advertisement -