Need to make a temp table look at the results from another temp table and only bring back results based on the list of people's ID's in the first temp table. I have both queries built and bringing back results.
Need to know how to link the two temp tables and bring back a result set based on both sets.
IF OBJECT_ID('tempdb..#TEMP1') IS NOT NULL
DROP TABLE #TEMP1
SELECT pat_mrn, pat_name, disch_date
IF OBJECT_ID('tempdb..#TEMP2') IS NOT NULL
DROP TABLE #TEMP2
SELECT pat.MRN, lab.ID
I need the pat_mrn, pat_name, disch_date, lab_id but ONLY if the pat_mrn is in both sets of data.