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

Top 5 Contributors of the Month
Melody Anderson

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

How to write query

Posted By: R@j     Posted Date: December 18, 2008    Points:2   Category :Sql Server
I have three tables(Interests,reg1,reg2)
1.Interests contains the below values
ID1 ID2 Interest
---- ---- --------
T100 T101 aasds
T100 T102 dgdsf

I have to get values from two tables reg1 and reg2(some fields from reg1 and some fields from reg2.Both reg1 and reg2 contains ID)
ID1 can contain T100 any number of times.
I want records of ID2 where ID1=T100 and bind to a datalist

Author: Rahul             
Posted Date: December 18, 2008     Points: 5   

You can use Inner Joid to build your SQL Query like this

select reg1.Col1,reg1.Col2,reg1.Col3,reg2.Col1,reg2.Col2,reg2.Col3,Interests.Col1,Interests.Col2,Interests.Col3 from Interests

Inner Join on Interests.IDCol = reg1.IDCol

InnerJoin on reg1.IDCol = reg2.IdCol

Where ID1=T100;

The above one is just sample SQL Query to build your SQL.

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

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