Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 149
  • Last Modified:

format fields

I have some fields in the database, where the information is already entered in an invalid way
suchas with spaces and or hyphens, I would like to remove them and put the whole variable in uppercase
0
bdipasquale
Asked:
bdipasquale
  • 2
1 Solution
 
Steve BinkCommented:
Use an UPDATE statement to change the data.  Make sure you take a backup of the existing data before starting your work.

UPDATE MyTable SET MyField=UPPER(MyField);
UPDATE MyTable SET MyField=REPLACE(MyField,'-','');
0
 
bdipasqualeAuthor Commented:
I dont want to do this because, the way it is in the database, is the way I want it, but Im sending the info to someone via xml, they require a phone number is sent to them like 5145551212, in our database its stored as 514-555-1212, so the formating needs to be done in php code, after taking the info from datbase so the info in db is not affected
0
 
Steve BinkCommented:
Or could create a copy of the table, change the data, then send the copy to your someone.  Delete the copy when you're done.

If you still want to do it in PHP, see these links:

http://www.php.net/manual/en/function.str-replace.php
http://www.php.net/manual/en/function.strtoupper.php
0

Featured Post

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now