Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8986981
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T21:40:54+00:00 2026-06-15T21:40:54+00:00

Thanks in advance on this one, again. I have a table which contains an

  • 0

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.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-15T21:40:55+00:00Added an answer on June 15, 2026 at 9:40 pm

    If you can split on the , that would probably be best. You can do that like this:

    UPDATE contactinfo
    SET MailingAddress = CONCAT(SUBSTRING_INDEX(MailingAddress, ',', 1), ',')
    

    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 CONCAT function.

    If you need to remove based on province code you can do it like this

    UPDATE contactinfo
    SET MailingAddress = TRIM(SUBSTRING_INDEX(MailingAddress, 'AB', 1));
    UPDATE contactinfo
    SET MailingAddress = TRIM(SUBSTRING_INDEX(MailingAddress, 'SK', 1));
    

    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, and aB. Obviously there are probably a number of addresses with ab in there so this would really cause problems in updating your data.

    Of course before you do anything, make a backup of your table.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Hi and thank you again for looking into this question. I have one mysql
First, thanks in advance for taking the time to read through this. I have
Similar questions to this one have been asked but none seem to address my
I have 2 tables. One table is 'headings' & contains Headings and the other
Assuming I have a table like this one: CREATE TABLE user_delegates ( [id] INT
This one has me pretty rattled so I thank you in advance for your
thanks in advance for looking at this. Essentially, I'm calling didInsertElement() and binding an
Thanks in Advance for reading and answer this question. I got button in asp
Thanks in advance for any help you can provide on this issue! I manage
Thanks in advance. This is my sample code. Whenever i try to run it

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.