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
 A puzzle - join related

Author  Topic 

soorajtnpki
Posting Yak Master

231 Posts

Posted - 2009-03-20 : 05:25:15
Hi all,
IF WE R GIVEN TWO TABLES JOIN RESULTS(LEFT,RIGHT AND INNER) ONLY, IS IT POSSIBLE TO FIND THOSE TABLE'S DATA

ASSUME THAT ALL THE THREE JOINS ARE DONE BASED ON ID..

THANX.......

RickD
Slow But Sure Yak Herding Master

3608 Posts

Posted - 2009-03-20 : 06:03:26
Yes, because you will get all the data as long as all the fields are included in the select statement and you know which fields belong to which table.
Go to Top of Page

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2009-03-20 : 09:25:40
quote:
Originally posted by soorajtnpki

Hi all,
IF WE R GIVEN TWO TABLES JOIN RESULTS(LEFT,RIGHT AND INNER) ONLY, IS IT POSSIBLE TO FIND THOSE TABLE'S DATA

ASSUME THAT ALL THE THREE JOINS ARE DONE BASED ON ID..

THANX.......




please refrain from using caps while posting
Go to Top of Page

gvphubli
Yak Posting Veteran

54 Posts

Posted - 2009-03-20 : 20:05:48
I don't think you will get to see all the data from both the tables in the join...here is what is documented in Books Online

---------------------------------------------------------
LEFT JOIN or LEFT OUTER JOIN

The result set of a left outer join includes all the rows from the left table specified in the LEFT OUTER clause, not just the ones in which the joined columns match. When a row in the left table has no matching rows in the right table, the associated result set row contains null values for all select list columns coming from the right table.


RIGHT JOIN or RIGHT OUTER JOIN

A right outer join is the reverse of a left outer join. All rows from the right table are returned. Null values are returned for the left table any time a right table row has no matching row in the left table.


FULL JOIN or FULL OUTER JOIN

A full outer join returns all rows in both the left and right tables. Any time a row has no match in the other table, the select list columns from the other table contain null values. When there is a match between the tables, the entire result set row contains data values from the base tables.
---------------------------------------------------------


TechnologyYogi
http://gvphubli.blogspot.com/
Go to Top of Page

RickD
Slow But Sure Yak Herding Master

3608 Posts

Posted - 2009-03-23 : 04:57:10
gvphubli - I'm interested why you think you won't get to see all the data in both dtables if you are using a combination of left and right joins (the inner is fairly irrelevant)?
Go to Top of Page
   

- Advertisement -