Splitting out existing records into separate fields

4 posts by 3 authors in: Forums > CMS Builder
Last Post: November 29, 2013   (RSS)

By zaba - November 27, 2013

Hi, I wonder if anyone can help me with this problem, its not technically a cmsb issue, but hoping some good hearted soul can help me with this.

I have an address field which is a text box containing the full address, i.e the filed contents will be something like "address 1 <br> address 2 <br> city  <br> postcode <br> country"

The client now wants this data in separate fields. I have no problem with changing this for all new records as the data is collected separately from a form and merged before it goes in to the database, the problem I have is all the thousands of existing records that need to be split and input into their relevant fields. 

Is there a way to do this as a php script I can run once or some snazzy sql that I can run in phpmyadmin on the database to split out the existing records into the new separate fields I have created?

please let me know if you need any more info.

Hi zaba,

Take a look at my recent post at,

http://www.interactivetools.com/forum/forum-posts.php?extracting-an-email-address-from-a-text-field-79134

Dave's input might be of some help.

In that approach, I think the trick is going to be finding a common pattern (like the <br>) to get the individual segments out of the array.

Wish I had a good solution for you but hopefully someone will.

Best,

Jerry Kornbluth

The first CMS Builder reference book is now available on-line!







Take advantage of a free 3 month trial subscription, only for CMSB users, at: http://www.thecmsbcookbook.com/trial.php

By zaba - November 29, 2013

Daryl,

thanks for this, I will take a look at your suggestion and report back, many thanks!