Thanks in advance on this one, again.
I have a table which contains an address record which I’m trying to break apart into it’s respective parts. Unfortunately the data I received wasn’t entered very consistently across entries, but there is one consistent element which I believe could be used to clean things up.
I’d basically like to get rid of everyone from the MailingAddress column AFTER (and including) the province (AB, SK) is listed so basically:
TABLE: contactinfo
MailingAddress: 1234 Something Street, AB A1B 2C4
would become
MailingAddress: 1234 Something Street,
I don’t want to remove the “,” as it is used in a lot of the street address information. I’d likely have to run query twice, as I’d also like to remove entries where the province starts “SK” as well.
You guys have been phenomenally helpful, and I really appreciate the assistance.
If you can split on the
,that would probably be best. You can do that like this:Note I have adding in the trailing comma, though it is unclear to me why you would need it. If you really don’t need it, just remove the wrapping
CONCATfunction.If you need to remove based on province code you can do it like this
Note that it is VERY important that you have a case sensitive collation on the MailingAddress filed in order for the above to work, otherwise the query won’t be able to tell the difference between
AB,ab,Ab, andaB. Obviously there are probably a number of addresses withabin there so this would really cause problems in updating your data.Of course before you do anything, make a backup of your table.