Home Forums SQL Server 2008 T-SQL (SS2K8) Left Join doesn't return all recodrs in left table RE: Left Join doesn't return all recodrs in left table

  • please check below codes.....

    declare @t1 table(id int,name varchar(10))

    insert into @t1(id,name) values(1,'A'),(2,'B'),(3,'C'),(4,'D'),(5,'E'),(6,'F'),(7,'G'),(8,'H'),(9,'I'),(10,'J')

    declare @t2 table(id int,name varchar(10))

    insert into @t2(id,name) values(1,'A'),(2,'B'),(3,'C'),(6,'F'),(8,'H')

    ----------------------LEFT JOIN------------------

    select T1.ID, T1.Name

    from @t1 t1

    left outer join @t2 t2 on t1.id=t2.id

    -------------------RIGHT JOIN

    select T1.ID, T1.Name

    from @t1 t1

    RIGHT outer join @t2 t2 on t1.id=t2.id