.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

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

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

Hi,
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
JavaScript/VBScriptBiztalkWPFPatten/PracticesWCFOthers
www.DotNetSpark.comUnAnsweredAll

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