C# .NET - sql query

Asked By sankar csharp on 02-Aug-10 02:20 AM
 difference betweeen left outer join and left inner join
shital patil replied to sankar csharp on 02-Aug-10 02:24 AM
You use INNER JOIN to return all rows from both tables where there is a match. ie. in the resulting table all the rows and colums will have values.


LEFT OUTER JOIN returns all the rows from the first table, even if there are no matches in the second table.
Anand Malli replied to sankar csharp on 02-Aug-10 02:33 AM
Hi Sankar

Left Outer Join
-----------------------
Even if both table does not have any common data it will still return all the data from left table,unlike Left join,so it means that left outer join will return all the rows that an inner join returns plus one row for each of the other rows in the first table that did not have a match in the second table

Left Inner Join
-----------------------
There is nothing like Left Inner Join,it is always Inner Join,so if you specified Inner Join,it will be still get only common data between the tables

let me know
thxs
Santhosh N replied to sankar csharp on 02-Aug-10 02:34 AM
INNER JOIN DISPLAYS ONLY THE RECORDS WHICH ARE SATISFYING
THE JOINING CONDITION,WHERE AS IN AN OUTER JOIN IT DISPLAYS
THE RECORDS WHICH ARE SATISFYING THE CONDITION AND ALSO
WHICH ARE NOT SATIFYING THE CONDITION ALSO.
check here for more info with an example of what i said above
http://www.allinterview.com/showanswers/59061.html
Jaya Nehru Kumar replied to sankar csharp on 02-Aug-10 02:35 AM
simply speaking inner join fetches the record if there is a match between two tables
and left outer join will fetches the record for every row  in  the left side table .. if there is no data in fetching column it will return as NULL
example :
Admission and Patient
both are having common ID PatientID
select admissiondate,PatientName
 from admission
left outer join Patient on Admission.PatientID=Patient.PatientID
where admissiondate = '2026-08-02'
The above query will fetch the list of all patient names who are all admitted today
admissiondate patientname
2010-08-02     X
null           Y

The null value represents there is no record for patient Y in admission table
but the row will be fetched since it is left outer join query
this row will not be fetched if it is nner join query
Hope this helps.
Sandra Jain replied to sankar csharp on 02-Aug-10 02:43 AM
You use INNER JOIN to return all rows from both tables where there is a match. ie. in the resulting table all the rows and colums will have values.

In OUTER JOIN the relulting table may have empty colums. Outer join may be either LEFT or RIGHT

LEFT OUTER JOIN returns all the rows from the first table, even if there are no matches in the second table.

RIGHT OUTER JOIN returns all the rows from the second table, even if there are no matches in the first table.
DL M replied to sankar csharp on 02-Aug-10 02:49 AM
Left Outer Join

A left outer join will return all the rows that an inner join returns plus one row for each of the other rows in the first table that did not have a match in the second table.

http://riteshshah.wordpress.com/2009/03/08/complete-ref-of-sql-server-join-inner-join-left-outer-join-right-outer-join-full-outer-join-in-sql-server-2005/