>Hi:
>How does the system join the multiple tables? Basically I need some visualization. I already tried the SQL Execution but I can’t understand. I found something in the web however his examples are all single joins
http://blog.sqlauthority.com/2009/04/13/sql-server-introduction-to-joins-basic-of-joins/.
>select *
>from table1 t1
> left outer join table2 t2 on t1.co1 = t2.co1
> left outer join table3 t3 on t2.co1 = t3.co1
> left outer join table4 t4 on t3.col = t4.col
>Please advise.
>
>Thanks,
>Jan
Jan,
The simplest way to understand would be to run a simple query, such as
declare @t1 table (ID int identity(1,1) primary key, cName varchar(10))
insert into @t1 (cName) values ('Jan'), ('Michael'),('Roman')
declare @t2 table (FK int not null , cName varchar(10))
insert into @t2 values (1,'Jan2'), (2,'Michael2'),(1, 'Roman2')
declare @t3 table (FK int not null , cName varchar(10))
insert into @t3 values (1,'Jan3'), (2,'Michael3'),(2, 'Roman3')
select T1.*, T2.cName as T2Name, T3.cName as T3Name from @t1 T1
LEFT JOIN @t2 T2 on T1.ID = T2.FK
LEFT JOIN @t3 T3 on T1.ID = T3.FK
If it's not broken, fix it until it is.
My Blog