IanMullineaux
Technical User
Hi
I am trying to joint 2 tables together but the fields i need to use are not identical..
The EPRFRef field in EPRMain is made up of 16 digits with a letter of the alphabet in position 17. This field has been taken accros into the EPRFVulnerable Adult table but the suffix has been changed to a different character - both fields are of type string.
The first 16 characters are identical and would therefor be ideal to use in the join but i dont know how to do this -
I have attempted to use LEFT to specify the first 16 characters of each field but get an error -
The sql statement is below:
SELECT "EPRFMain"."IncidentNumber", "EPRFMain"."IncidentDate", "EPRFMain"."Callsign", "EPRFMain"."Crew1Pin", "EPRFMain"."Crew2Pin", "EPRFVulnerableAdult"."VAGender", "EPRFVulnerableAdult"."VAAdultDob", "EPRFVulnerableAdult"."VAEthnicity", "EPRFVulnerableAdult"."VAPhysicalAbuse", "EPRFVulnerableAdult"."VASexualAbuse", "EPRFVulnerableAdult"."VAEmotionalAbuse", "EPRFVulnerableAdult"."VAFinancialAbuse", "EPRFVulnerableAdult"."VANeglect", "EPRFVulnerableAdult"."VADiscriminatoryAbuse", "EPRFVulnerableAdult"."VAPhysicalSigns", "EPRFVulnerableAdult"."VAInconsistentStory", "EPRFVulnerableAdult"."VABehaviouralSigns", "EPRFVulnerableAdult"."VAEnvironment", "EPRFVulnerableAdult"."VADisclosure", "EPRFVulnerableAdult"."VAVulnerableWhy", "EPRFVulnerableAdult"."VAConcerned", "EPRFVulnerableAdult"."VAConveyed", "EPRFVulnerableAdult"."VADangerIfNotConveyed", "EPRFVulnerableAdult"."VAAdultName", "EPRFVulnerableAdult"."VAAdultAddress", "EPRFVulnerableAdult"."VADescWhyVulnerable", "EPRFVulnerableAdult"."VAGP", "EPRFVulnerableAdult"."VADescConcerns", "EPRFVulnerableAdult"."VADescEvents", "EPRFVulnerableAdult"."VAReportedTo"
FROM "EPRFwarehouse"."dbo"."EPRFVulnerableAdult" "EPRFVulnerableAdult" INNER JOIN "EPRFwarehouse"."dbo". "EPRFMain" ON LEFT("EPRFVulnerableAdult"."VAEprfRef",16)=LEFT("EPRFMain"."EprfRef",16)
could anyone tell me how to make this work please...
I am trying to joint 2 tables together but the fields i need to use are not identical..
The EPRFRef field in EPRMain is made up of 16 digits with a letter of the alphabet in position 17. This field has been taken accros into the EPRFVulnerable Adult table but the suffix has been changed to a different character - both fields are of type string.
The first 16 characters are identical and would therefor be ideal to use in the join but i dont know how to do this -
I have attempted to use LEFT to specify the first 16 characters of each field but get an error -
The sql statement is below:
SELECT "EPRFMain"."IncidentNumber", "EPRFMain"."IncidentDate", "EPRFMain"."Callsign", "EPRFMain"."Crew1Pin", "EPRFMain"."Crew2Pin", "EPRFVulnerableAdult"."VAGender", "EPRFVulnerableAdult"."VAAdultDob", "EPRFVulnerableAdult"."VAEthnicity", "EPRFVulnerableAdult"."VAPhysicalAbuse", "EPRFVulnerableAdult"."VASexualAbuse", "EPRFVulnerableAdult"."VAEmotionalAbuse", "EPRFVulnerableAdult"."VAFinancialAbuse", "EPRFVulnerableAdult"."VANeglect", "EPRFVulnerableAdult"."VADiscriminatoryAbuse", "EPRFVulnerableAdult"."VAPhysicalSigns", "EPRFVulnerableAdult"."VAInconsistentStory", "EPRFVulnerableAdult"."VABehaviouralSigns", "EPRFVulnerableAdult"."VAEnvironment", "EPRFVulnerableAdult"."VADisclosure", "EPRFVulnerableAdult"."VAVulnerableWhy", "EPRFVulnerableAdult"."VAConcerned", "EPRFVulnerableAdult"."VAConveyed", "EPRFVulnerableAdult"."VADangerIfNotConveyed", "EPRFVulnerableAdult"."VAAdultName", "EPRFVulnerableAdult"."VAAdultAddress", "EPRFVulnerableAdult"."VADescWhyVulnerable", "EPRFVulnerableAdult"."VAGP", "EPRFVulnerableAdult"."VADescConcerns", "EPRFVulnerableAdult"."VADescEvents", "EPRFVulnerableAdult"."VAReportedTo"
FROM "EPRFwarehouse"."dbo"."EPRFVulnerableAdult" "EPRFVulnerableAdult" INNER JOIN "EPRFwarehouse"."dbo". "EPRFMain" ON LEFT("EPRFVulnerableAdult"."VAEprfRef",16)=LEFT("EPRFMain"."EprfRef",16)
could anyone tell me how to make this work please...