CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 3 of 3

Thread: JOIN Tables

  1. #1
    Join Date
    Feb 2009
    Posts
    192

    JOIN Tables

    Hi,

    I have 2 tables TableA and TableB

    TableA

    Code:
    MedicalCodeID    EmisCode     ReadCode    
    1                EMISATT      NULL          
    2                NULL         PCSDT         
    3                TFHG         Hgi           
    4                YUGH         NULL
    TableB

    Code:
    DiaryID          EmisCode     ReadCode    
    1                EMISATT_AB     NULL        
    2                EMISATT_C      NULL        
    3                TFHG           Hgi         
    4                YUGH           NULL
    Results I want to receive;

    Code:
    DiaryID          MedicalCodeID 
    1                1                   
    2                1      
    3                3           
    4                4
    Therefore, the idea is if the emiscode = EMISATT% on TableB take medicalcodeID = 1, otherwise, take the exact match.

    Code of the JOIN I have now is as shown (this code takes the exact match of the emiscode) but I want to update it to obtain the above results - where it will pull the EMISATT if the first 7 characters start with EMISATT, otherwise do exact match

    Code:
    ISNULL(TableB.EmisCode, N'(novalue)') = ISNULL(TableA.Emiscode, N'(novalue)')
    Thank you so much

  2. #2
    Join Date
    Jul 2008
    Location
    WV
    Posts
    5,362

    Re: JOIN Tables

    I am confused you say the code of the Join is as shown but you have not shown any join code.
    Always use [code][/code] tags when posting code.

  3. #3
    Join Date
    Feb 2009
    Posts
    192

    Re: Compare Fields

    Sorry My mistake ..

    What I meant was the comparison between the two fields, and that should yield the results as shown above..

    Thanks

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

Featured