Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 4587436
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 21, 20262026-05-21T21:46:50+00:00 2026-05-21T21:46:50+00:00

First post, have been searching extensively for a month for an answer to this

  • 0

First post, have been searching extensively for a month for an answer to this and figured I would just ask the experts.

I have populated a table with patient accounts that have received services at a hospital. I am pulling columns listing the performing physician on each of their procedures. The values of those columns are sequence numbers that point me to a set of columns in a second table. The columns in the second table actually contain the physician identifiers I need.

Example:

TABLE 1

Account:       Phys_Proc1     Phys_Proc2     PhysProc3     PhysProc4     PhysProc5`

Patient1       2              5              1             4             5
Patient2       1              3              3             4             0
Patient3       2              0              0             0             0

TABLE 2

Account:       Physician1     Physician2     Physician3    Physician4    Physician5

Patient1       500123         500456         500789        600123        600456
Patient2       400321         500700         300876        456789        987654
Patient3       300500         800700         0             0             0

I need up update the records in TABLE 1 with the values from TABLE 2 where the value in TABLE 1 refers to the column name from TABLE 2.

EXAMPLE

Patient1 had procedure1 performed by ‘500456’ (Phys_Proc1’s value is “2” which refers to the Physician2 field in TABLE 2.)

Any help would be greatly appreciated. Even a hint at this point would give me a direction to look in. Pointing me toward a specific function name to search is better than what I have now (nothing.) I tried an extensive CASE statement but it didn’t pull the values for each patient account and pulled the values from TABLE 2 for the first account and applied it to all patient records.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-21T21:46:51+00:00Added an answer on May 21, 2026 at 9:46 pm
    UPDATE Table2 
    SET 
    Physc_Proc1 = 
        CASE WHEN Phys_Proc1 = 1 Then Table2.Physician1 
        CASE WHEN Phys_Proc1 = 2 Then Table2.Physician2 
        CASE WHEN Phys_Proc1 = 3 Then Table2.Physician3 
        CASE WHEN Phys_Proc1 = 4 Then Table2.Physician4 
        CASE WHEN Phys_Proc1 = 5 Then Table2.Physician5
        ELSE NULL 
    END, 
    
    Physc_Proc2 = 
        CASE WHEN Phys_Proc2 = 1 Then Table2.Physician1 
        CASE WHEN Phys_Proc2 = 2 Then Table2.Physician2 
        CASE WHEN Phys_Proc2 = 3 Then Table2.Physician3 
        CASE WHEN Phys_Proc2 = 4 Then Table2.Physician4 
        CASE WHEN Phys_Proc2 = 5 Then Table2.Physician5
        ELSE NULL 
    END, 
    
    PhyscProc3 = 
        CASE WHEN PhysProc3 = 1 Then Table2.Physician1 
        CASE WHEN PhysProc3 = 2 Then Table2.Physician2 
        CASE WHEN PhysProc3 = 3 Then Table2.Physician3 
        CASE WHEN PhysProc3 = 4 Then Table2.Physician4 
        CASE WHEN PhysProc3 = 5 Then Table2.Physician5
        ELSE NULL 
    END, 
    
    PhyscProc4 = 
        CASE WHEN PhysProc4 = 1 Then Table2.Physician1 
        CASE WHEN PhysProc4 = 2 Then Table2.Physician2 
        CASE WHEN PhysProc4 = 3 Then Table2.Physician3 
        CASE WHEN PhysProc4 = 4 Then Table2.Physician4 
        CASE WHEN PhysProc4 = 5 Then Table2.Physician5
        ELSE NULL 
    END, 
    
    PhyscProc5 = 
        CASE WHEN PhysProc5 = 1 Then Table2.Physician1 
        CASE WHEN PhysProc5 = 2 Then Table2.Physician2 
        CASE WHEN PhysProc5 = 3 Then Table2.Physician3 
        CASE WHEN PhysProc5 = 4 Then Table2.Physician4 
        CASE WHEN PhysProc5 = 5 Then Table2.Physician5
        ELSE NULL 
    END
    FROM Table2
    INNER JOIN Table1
    ON Table2.Account = Table1.Account
    

    Note: I haven’t tried this for syntax. I hope this gives you an idea on how to proceed further.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Hello all this is my first post here i have been working in an
This is my first post, have been a lurker for a long time, so
Well, this is my first post here and really enjoying the site. I have
This is my first post here. I have a problem. I need to take
this is my first post on this great source of programming information. I have
This is going to be a long post. I would like to have suggestions
This is my first post and I have the feeling that this is something
I have been reading this post on the codeigniter forum, http://codeigniter.com/forums/viewthread/174928/ and it has
this is my first post, and it covers something which I've been trying to
I have been trying to follow the example in this post . Since I

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.