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.
Example:
IF OBJECT_ID('tempdb..#TEMP1') IS NOT NULL
DROP TABLE #TEMP1
GO
SELECT pat_mrn, pat_name, disch_date
INTO #TEMP1
FROM ...
WHERE...
-----then
IF OBJECT_ID('tempdb..#TEMP2') IS NOT NULL
DROP TABLE #TEMP2
GO
SELECT pat.MRN, lab.ID
INTO #TEMP2
FROM...
WHERE...
---now what?
I need the pat_mrn, pat_name, disch_date, lab_id but ONLY if the pat_mrn is in both sets of data.
Our community of experts have been thoroughly vetted for their expertise and industry experience.