.NET Tutorials, Forums, Interview Questions And Answers
Welcome :Guest
 
Sign In
Register
 
Win Surprise Gifts!!!
Congratulations!!!


Top 5 Contributors of the Month
david stephan

Home >> Forum >> Sql Server >> Post New QuestionBookmark and Share Subscribe to Forum

Need a sql query

Posted By: Senthilnathan     Posted Date: April 06, 2011    Points:5   Category :Sql Server
Hi friends,

I have a table like below,


account_no linked_acc_no
--------- -------------

aaa bbb
bbb ccc
bbb ddd
eee ccc
ddd fff
fff ggg
eee hhh
hhh iii
xxx zzz
xxx yyy
vvv www

I need a query to select account no which are linked with 'aaa'.
So the o/p should be like this,

o/p
---
bbb
ccc
ddd
eee
fff
ggg
hhh
iii


any one can help me on this?..



Responses
Author: Naresh             
Posted Date: April 06, 2011     Points: 20   

hi senthil,

ur question is little bit confusing, can u give cleary so i can help u

i think u need column A where Column A present in Column B.


then

Select ColumnA from table where ColumnA IN (Select Columnb from table)

Thanks
Naresh
Author: Senthilnathan             
Posted Date: April 06, 2011     Points: 20   

Hi Naresh,

I got a solutions.

Thanks.

Author: Maverick             
Posted Date: April 06, 2011     Points: 20   

Hi,

Does you table got hierarchical relation ship?
If yes then use CTE of sql server

Thanks,
Maverick

Thanks,
Maverick
Author: shankey             
Posted Date: April 06, 2011     Points: 20   

Hi,

I support maverick, It is possible using Common Table Expression feature of sql server

Shankey


Post Reply

You must Sign In To post reply
 
 
Find more Forum Questions on C#, ASP.Net, Vb.Net, SQL Server and more Here
Quick Links For Forum Categories:
ASP.NetWindows Application  .NET Framework  C#  VB.Net  ADO.Net  
Sql Server  SharePoint  OOPs  SilverlightIISJQuery
JavaScript/VBScriptBiztalkWPFPatten/PracticesWCFOthers
www.DotNetSpark.comUnAnsweredAll

Hall of Fame    Twitter   Terms of Service    Privacy Policy    Contact Us    Archives   Tell A Friend