错误的参数数量错误

时间:2010-06-29 21:18:51

标签: sql ms-access

这个查询给了我错误。我在2个表中寻找两个相似的字母

SELECT clients.ClinicName, clinics.clinicName, 
       clinics.ClientID, clients.[Clinic ID]  
FROM clients, clinics  
WHERE Left(clients.ClinicName, Instr(Instr(clients.ClinicName," ")  
+1,clients.ClinicName," ")-1) = Left(Instr(clinics.clinicName," ")  
+1,clinics.clinicName, Instr(clinics.clinicName," ")-1);  

由于

1 个答案:

答案 0 :(得分:2)

Left(str, count)需要字符串和整数计数,InStr(str, substr)需要字符串和子字符串,返回一个整数。

重新格式化您的样本,您可以看到参数的数量和参数的类型不匹配:

WHERE Left(clients.ClinicName,
           Instr(Instr(clients.ClinicName," ")+1,
                 clients.ClinicName," ")-1) =
      Left(Instr(clinics.clinicName," ")+1,
           clinics.clinicName,
           Instr(clinics.clinicName," ")-1);

我相信你想要这样的东西(但我无法猜测你的意图):

WHERE Left(clients.ClinicName, Instr(clients.ClinicName," ")-1) =
      Left(clinics.clinicName, Instr(clinics.clinicName," ")-1);