Results 1 to 3 of 3
  1. #1
    Join Date
    Feb 2004
    Location
    Australia
    Posts
    183

    Unhappy Unanswered: multiple left joins help?

    Could somebody tell me what is the secret of being able to write a SELECT statement having mulitple LEFT or RIGHT joins, I seem to get in trouble as soon as I add the second LEFT join, as I am obviously doing it wrong.



    These are my tables, would somebody mind having a go,or explaining what do i need to be aware of in a case like this



    emailDetails table ( emailID_PK,emailName,emailText,emailSubject,emailN otificationTypeID)

    emailRecipients table (emailID_PK, RecipientID, SentToEmail)

    luEmailNotificationTypes look up table (emailNOtificationTypeID_PK, emailNotificationTypeName)



    Thanks

  2. #2
    Join Date
    Feb 2004
    Location
    In front of the computer
    Posts
    15,579
    Provided Answers: 54
    I'd suggest using something like:
    PHP Code:
    SELECT foo -- to make Rudy happy!
       
    FROM emailDetails AS d
       LEFT JOIN emailRecepients 
    AS r
          ON 
    (r.emailID_PK d.emailID_PK)
       
    LEFT JOIN luEmailNotificationTypes AS t
          ON 
    (t.emailNOtificationTypeID_PK d.[emailN otificationTypeID]) 
    The key to the whole process is to ensure that the table with the most detail is the "outermost" table in the JOIN. You can then do LEFT JOIN operations to the other tables without having to go to extrordinary lengths to make them "play nice" together.

    -PatP

  3. #3
    Join Date
    Feb 2004
    Location
    Australia
    Posts
    183
    thank you very much,nice work

Posting Permissions

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