jim.davidson Posted May 31, 2007 Share Posted May 31, 2007 I'm new to mySQL and have a very simple question. I have a table of states I want to add two spaces to the front of the name. I'm thinking this will do it but want to validate before I screw it up Will this do it? update states set state_name = " "+state_name Or is it going to try to do an artithmatic operation and wipe out the state_name? Quote Link to comment https://forums.phpfreaks.com/topic/53765-solved-need-help-with-query/ Share on other sites More sharing options...
Wildbug Posted May 31, 2007 Share Posted May 31, 2007 I think you want CONCAT(). UPDATE states SET state_name=CONCAT(" ",state_name); Quote Link to comment https://forums.phpfreaks.com/topic/53765-solved-need-help-with-query/#findComment-265759 Share on other sites More sharing options...
jim.davidson Posted May 31, 2007 Author Share Posted May 31, 2007 Thank you See, something told me that was wrong, you saved me from retyping all those names. Thanks again Quote Link to comment https://forums.phpfreaks.com/topic/53765-solved-need-help-with-query/#findComment-265766 Share on other sites More sharing options...
fenway Posted May 31, 2007 Share Posted May 31, 2007 Why on earth do you want to corrupt your DB with formatting? And LPAD() would be the more correct solution... and you should be doing it on OUTPUT ONLY. Quote Link to comment https://forums.phpfreaks.com/topic/53765-solved-need-help-with-query/#findComment-265771 Share on other sites More sharing options...
Wildbug Posted May 31, 2007 Share Posted May 31, 2007 Why on earth do you want to corrupt your DB with formatting? And LPAD() would be the more correct solution... and you should be doing it on OUTPUT ONLY. Agreed. (Give them what they want, not what they ask for.) Quote Link to comment https://forums.phpfreaks.com/topic/53765-solved-need-help-with-query/#findComment-265779 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.