• hiC rusty hop u will get it by reading below code

  • Create table Doc (

    DocNum nvarchar(15) NOT NULL

    );

    Insert into Doc (DocNum)

    Values ('1');

    ------------------------------

    Create Table GR (

    DocNum nvarchar(15) NOT NULL,

    GR nvarchar(15) NOT NULL,

    Seq intNOT NULL

    )

    Insert into GR (DocNum, GR, Seq) Values (1,'A',1)

    Insert into GR (DocNum, GR, Seq) Values (1,'B',2)

    --------------------------------

    Create Table GE (

    DocNum nvarchar(15) NOT NULL,

    GE nvarchar(15) NOT NULL,

    Seq intNOT NULL

    )

    Insert into GE (DocNum, GE, Seq) Values (1,'A',1)

    Insert into GE (DocNum, GE, Seq) Values (1,'B',2)

    Insert into GE (DocNum, GE, Seq) Values (1,'C',3)

    --------------------------------------------------

    Create Table Ref (

    DocNum nvarchar(15) NOT NULL,

    Ref nvarchar(15) NOT NULL,

    Seq intNOT NULL

    )

    Insert into Ref (DocNum, Ref, Seq) Values (1,'A',1)

    Insert into Ref (DocNum, Ref, Seq) Values (1,'B',2)

    Insert into Ref (DocNum, Ref, Seq) Values (1,'C',3)

    Insert into Ref (DocNum, Ref, Seq) Values (1,'D',4)

    Insert into Ref (DocNum, Ref, Seq) Values (1,'E',5)

    -------

    select * from Ref

    left join GE

    on ref.DocNum=GE.DocNum

  • See the output of bold part of query

    as Ref have 5 values "1" in DocNum

    and GE have 3 values "1" in DocNum

    so output will have 15 rows as join behave row by row.