I have two tables that look like this.
Table Applicant
LName FName MI
Adamson Leon R
Alfano Vincent
Bost Darrod D
Table ApplicantScore
ID Name Score
1 Adamson, Leon R. 89
2 Alfano, Vincent 99
3 Bost, Darrod D. 81
4 Smith, John 90
5 Chen, Lao 90
...
Any name that has an MI ends with a period.
I need to use the data in the table Applicant to retrieve the information from the table ApplicantScore. So, in the end, it will look like,
ID Name Score
1 Adamson, Leon R 89
2 Alfano, Vincent 99
3 Bost, Darrod D 81
I am using this SQL, but I am not getting what I need.
select a.ID, a.name, a.score
from Applicant a
left join ApplicantScore b
on (REPLACE(b.Name, ' ', '') = REPLACE(a.LName + ',' + a.FName +
ISNULL(a.MI, ''), ' ', ''));
The result I get is:
ID Name Score
NULL NULL NULL
2 Alfano, Vincent 99
NULL NULL NULL
Help, please?