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
 get data from multiple table

Author  Topic 

younas02
Starting Member

28 Posts

Posted - 2013-08-21 : 13:13:48
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
Master Smack Fu Yak Hacker

3873 Posts

Posted - 2013-08-21 : 13:23:59
[code]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
[/code]
Go to Top of Page
   

- Advertisement -