tags:

views:

42

answers:

1

this query is giving me error. I am looking for two similar letters in the 2 tables

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);  

Thanks

+2  A: 

Left(str, count) requires a string and an integer count, and InStr(str, substr) requires a string and a substring, returning an integer.

Reformatting your sample, you can see that the number of parameters and types of parameters don't match:

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

I believe you want something like this (but I can't guess your intent):

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