Results 1 to 4 of 4

Thread: [RESOLVED] Case statement in inner join

Threaded View

  1. #1

    Thread Starter
    King of sapila
    Join Date
    Oct 2006
    Location
    Greece
    Posts
    6,763

    Resolved [RESOLVED] Case statement in inner join

    Hi.
    MS SQL , is there a way to case so you can have a different join per contrition?

    So something like:

    Code:
    select * from TBank  T
    inner join tblDWLoyaltyMember L on (Case WHEN  ISNUMERIC(T.LoyaltyMemberCode) = 1 THEN (L.LoyaltyMemberCode = T.LoyaltyMemberCode) ELSE (L.MembershipID = T.LoyaltyMemberCode) END)
    ELSE I only seem to think of this:
    Code:
    left join tblDWLoyaltyMember L  on L.MembershipID = T.LoyaltyMemberCode 
    left join tblDWLoyaltyMember L1 on L1.LoyaltyMemberCode = T.LoyaltyMemberCode
    but I'm not sure if this is correct as I left join something that I wan to only be on inner join

    Thanks.
    Last edited by sapator; Apr 13th, 2023 at 05:38 AM.
    ἄνδρα μοι ἔννεπε, μοῦσα, πολύτροπον, ὃς μάλα πολλὰ
    πλάγχθη, ἐπεὶ Τροίης ἱερὸν πτολίεθρον ἔπερσεν·

Posting Permissions

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



Click Here to Expand Forum to Full Width