SQL Joins

Q

What is the difference between Inner Join and Outer Join?

✍: Guest

A
1. 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. 2. An inner join is join in which the values in the columns being joined are compared using the comparision operator. Using where clause is the back dated method of comparision. eg. SELECT * FROM authors AS a INNER JOIN publishers AS p ON a.city = p.city ORDER BY a.au_lname DESC 3. Inner join displays rows from table where the data is availabe in both the tables, where in outer join we can configure it to bring out rows from one table where the data is missing in other table for the corresponding rows.

2008-09-25, 5143👍, 0💬