Go Back   CodingForums.com > :: Server side development > MySQL

Before you post, read our: Rules & Posting Guidelines

Reply
 
Thread Tools Rate Thread
Enjoy an ad free experience by logging in. Not a member yet? Register.
Old 07-30-2011, 05:00 PM   PM User | #1
nickburrett
New Coder

 
Join Date: Jun 2009
Posts: 63
Thanks: 22
Thanked 0 Times in 0 Posts
nickburrett is an unknown quantity at this point
Update and Replace

Would I be right in saying that the following update statement will replace 1 with 01 and 14 with 014.

I only want it to replace 1 with 01 - how do I achieve this?

Code:
update bookings set eventMonth = replace(eventMonth, '1', '01')
nickburrett is offline   Reply With Quote
Old 07-30-2011, 09:44 PM   PM User | #2
Old Pedant
Supreme Master coder!

 
Old Pedant's Avatar
 
Join Date: Feb 2009
Posts: 23,162
Thanks: 59
Thanked 3,992 Times in 3,961 Posts
Old Pedant is a name known to allOld Pedant is a name known to allOld Pedant is a name known to allOld Pedant is a name known to allOld Pedant is a name known to allOld Pedant is a name known to all
Ummm...it depends on what kind of field eventMonth is.

If eventMonth is an integer, for example, either that code will do nothing or it will cause an error.

But if eventMonth is a text field of some kind, you are correct.

But why not find out?

Code:
SELECT replace(eventMonth,'1','01') FROM bookings
What do you get?
Old Pedant is offline   Reply With Quote
Reply

Bookmarks

Jump To Top of Thread


Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +1. The time now is 06:39 PM.


Advertisement
Log in to turn off these ads.