Skip to main content

Posts

Showing posts from August, 2012

Joins in sql

Join To return  a result set, combined from multiple tables joins are implemented . lets take the  two tables below for study.  Inner Join when inner join is applied it selects the rows which matches the join fields in both the table (simply it is called a join). query:                select s.StudentId,s.TeacherId,s.Name as student_name,t.Name as teacher_name                       from Student s   inner join Teacher t                       on s.TeacherId=t.TeacherId  result: Outer Join Left outer join Returns all rows from the left table (that means the table specified first in select statement) and only the matching rows from the next table(matching refers to the join fields being equal) query :            select s.studentId,s.teacherId,s.name as student_name,t.name as teacher_name                        from Student s left join teacher t on s.teacherId=t.teacherId order by t.Name result :  Right Outer Join Similar to