SQL Server Forums
Profile | Register | Active Topics | Members | Search | Forum FAQ
 
Register Now and get your question answered!
Username:
Password:
Save Password
Forgot your Password?

 All Forums
 General SQL Server Forums
 New to SQL Server Programming
 get data from multiple table
 New Topic  Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic  

younas02
Starting Member

Pakistan
28 Posts

Posted - 08/21/2013 :  13:13:48  Show Profile  Reply with Quote
i have 3 tables
say table1 , table2 and table3
table1 have three columns say name,lastname, id2
table2 have 3 columns say details,id2,id3
table3 have 3 columns say payment,id3 ,session

i have to get data as
select * from table1
then
select * from table2 where id2=table1.id
then
select * from table3 where id3=table2.id3 and session=something say 4

James K
Flowing Fount of Yak Knowledge

3706 Posts

Posted - 08/21/2013 :  13:23:59  Show Profile  Reply with Quote
SELECT t1.col1, t1.col2, t2.col1, ...
FROM
	Table1 t1
	INNER JOIN Table2 t2 ON t2.id2 = t1.id
	INNER JOIN Table3 t3 ON t3.id3 = t2.id2
WHERE	t3.[sessio]n = 4
Go to Top of Page
  Previous Topic Topic Next Topic  
 New Topic  Reply to Topic
 Printer Friendly
Jump To:
SQL Server Forums © 2000-2009 SQLTeam Publishing, LLC Go To Top Of Page
This page was generated in 0.03 seconds. Powered By: Snitz Forums 2000