Try changing the line to:
. . .
appointment.[Appt Location] LIKE 'D&A%' and nap.[Service Unit Name] LIKE 'D&A%'
. . .
This browser is no longer supported.
Upgrade to Microsoft Edge to take advantage of the latest features, security updates, and technical support.
Hi there,
I have two tables Appointments and NAP.
I need to join them with logic below -
appointment [(appt location starts with 'D&A') & MRN & Appt Date] = NAP [(SU name starts with 'D&A') & MRN & Appt Date]
How to do the first part in SQL Server query -
appointment
left outer join NAP
on
left(app.[Appt Location],3) and left(nap3.[Service Unit Name],3) ='D&A'
appointment .MRN= NAP .MRN and
appointment .[Appt Date] =NAP .[Service Date]
Thanks
Try changing the line to:
. . .
appointment.[Appt Location] LIKE 'D&A%' and nap.[Service Unit Name] LIKE 'D&A%'
. . .
Hi,@kkran
Welcome to Microsoft T-SQL Q&A Forum!
Here is a comparison article about the performance of like and where, I believe it will be more helpful to you. Please check this:
select *
from appointment AP left outer join NAP
on NAP.MRN =AP.MRN and NAP.[Service Date]=AP.[Appt Date]
Where left(AP.[Appt Location],3)='D&A'
and left(nap.[Service Unit Name],3) ='D&A'
Best regards,
Bert Zhou
If the answer is the right solution, please click "Accept Answer" and kindly upvote it. If you have extra questions about this answer, please click "Comment".
Note: Please follow the steps in our Documentation to enable e-mail notifications if you want to receive the related email notification for this thread.