Hello - I've searched the forum and read through all of the SQL examples on InStr and InStrRev but I could not find an example that would help me do the following:
I have a username field with entries as such:
Dennis Johnson - AP Supervisor
I'm trying to parse the field into Firstname, LastName, JobTitle using SQL (not code module). My query thus far is:
SELECT
Left([UserNAME],InStr([UserNAME]," ")-1) as Firstname,
Left([UserNAME],InStrRev(rtrim([UserNAME]),'- ')-2) as LastName,
Mid([UserNAME],InStr([UserNAME],"-")+1) as Position
From Users;
The results for the 'Firstname' and 'Position' come back fine; however, the lastname does not work properly. It returns the First and Lastname together. I've experimented with all the examples in my search, however nothing has worked.
Any help would be greatly appreciated.
Thanks.
I have a username field with entries as such:
Dennis Johnson - AP Supervisor
I'm trying to parse the field into Firstname, LastName, JobTitle using SQL (not code module). My query thus far is:
SELECT
Left([UserNAME],InStr([UserNAME]," ")-1) as Firstname,
Left([UserNAME],InStrRev(rtrim([UserNAME]),'- ')-2) as LastName,
Mid([UserNAME],InStr([UserNAME],"-")+1) as Position
From Users;
The results for the 'Firstname' and 'Position' come back fine; however, the lastname does not work properly. It returns the First and Lastname together. I've experimented with all the examples in my search, however nothing has worked.
Any help would be greatly appreciated.
Thanks.