Results 1 to 2 of 2

Thread: left join

  1. #1
    Join Date
    Aug 2006
    Posts
    39

    Unanswered: left join

    There are two tables:
    tblIndices:
    IndexID, Name
    1 index1
    2 index2
    3 index3
    .
    .
    .


    tblBasketConstituents
    ID, ParentIndexID, ChildIndexID, Weight
    1 2 1 20
    2 2 3 80
    3 1 3 50
    4 1 2 50

    As you can see the ParentIndexID and ChildIndexID fields refer to tblIndices.IndexID
    I would like a stored procedure as follows:
    show all index names and show the wights for the indexID you passed.
    This is what I have so far and it is not correct yet. Not sure what the syntax should be.


    alter PROCEDURE [dbo].[uspBasketIndices_Get]

    @IndexID int

    AS

    select
    i.IndexID,
    i.[Name],
    bc.Weight
    from
    tblIndices as i left join tblBasketConstituents as bc on i.IndexID = bc.ParentIndexID
    and i.IndexID = @IndexID
    order by
    i.[Name]

  2. #2
    Join Date
    Aug 2006
    Posts
    39
    parentindex to be used after and

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •