declare variable $mRec := "010155-00";
for $pi in /NTSFP10/dbo_PatRefInfo/ROW
for $pa in /NTSFP10/dbo_Patient/ROW
where $pi/PatientID = $pa/PATID and $pa/PATID = $mRec
return ($pa/PATID)
Nothing is returned, but I have verified the mRec exists in each table. both are nvarchar or varchar Sample data file