I am fairly new to SQL and have been able to run queries from a single table in a single DB. But now I need to access the codes and their true values from another table in another DB and I'm not sure how to do that. It probably involves the JOIN command but I haven't been able to make it work.
Here is a summary of my data:
DB1.Table1
Procedure Code Procedure Description PIC Code ID
----------------------------------------------------
10005001 INJECTION 20ML 707
10005002 INJECTION 30ML 707
20008850 BLOOD CBC 254
DB2.Table2
PIC Code ID PIC Code PIC Code Description
---------------------------------------------
707 250 PHARMACY
707 250 PHARMACY
254 300 LABORATORY
My query starts in DB1.Table1 but I am to be able to link to DB2.Table2 and return the value in column PIC Code instead of PIC Code ID.
So the output would be similar to:
Procedure Code Procedure Description PIC Code
-------------------------------------------------
10005001 INJECTION 20ML 250
10005002 INJECTION 30ML 250
20008850 BLOOD CBC 300
The PIC Code ID is an index that is used at run time and not the true code that the end user would recognize.