iPixel Posted August 2, 2010 Share Posted August 2, 2010 Ok i need to do this for both MySQL & Oracle, but once i see how the mysql version works i can figure out the oracle way (hopefully). I have 2 columns which contain numbers such as 2707, 23, 000289 etc... as you can see they range from 2 to 6 characters, and i need them all to be 6 characters. How could i write an update sql statement that would change all the #'s to 002707,000023,000289 etc... Thanks! Quote Link to comment https://forums.phpfreaks.com/topic/209581-need-help-with-update-statement/ Share on other sites More sharing options...
Barand Posted August 2, 2010 Share Posted August 2, 2010 MySQL solution - specify the column as int(6) and zerofill Quote Link to comment https://forums.phpfreaks.com/topic/209581-need-help-with-update-statement/#findComment-1094166 Share on other sites More sharing options...
PFMaBiSmAd Posted August 2, 2010 Share Posted August 2, 2010 What's the data type definition for the column? If it's a string type, you would pad the values with zero's. if it's a numeric type, you would redefine the column to have a specific size with zero fill. Or you could just handle the zero pad/fill when you retrieve the data in your query or when you display the data in your php code. Quote Link to comment https://forums.phpfreaks.com/topic/209581-need-help-with-update-statement/#findComment-1094168 Share on other sites More sharing options...
fenway Posted August 4, 2010 Share Posted August 4, 2010 Don't corrupt the raw data with an arbitrary number of zeroes. Quote Link to comment https://forums.phpfreaks.com/topic/209581-need-help-with-update-statement/#findComment-1095218 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.