您应该在where子句中使用join或use exists与join一起使用。
SELECT PD.PRACTITIONERID, PD.LastName, PD.FirstName, PD.NationalProviderID
FROM vwPractitionerDemographics PD
WHERE EXISTS
(SELECT 1
FROM vwPractitionerLocations
WHERE PracticeTaxIDNumber = '59-1205165'
AND vwPractitionerLocations.[matching column here] = PD.[matching column here])
SELECT PD.PRACTITIONERID, PD.LastName, PD.FirstName, PD.NationalProviderID
FROM vwPractitionerDemographics PD INNER JOIN vwPractitionerLocations ON vwPractitionerLocations.[matching column here] = PD.[matching column here])
WHERE PracticeTaxIDNumber = '59-1205165'
SQL Server无法猜测您希望表在查询中如何相互关联,您必须显式地提供该信息。使用
IN
,在本例中
, was not correct as it should be used when evaluating multiple values. In your case you are passing a single value to be evaluated. If you really want to use IN then you would write
…其中practicetaxidnumber in('59-1205165')`但我认为您可以看到,对于1个值,这没有多大意义。