Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 2 of 2
  1. #1
    New Coder
    Join Date
    Jun 2009
    Posts
    68
    Thanks
    22
    Thanked 0 Times in 0 Posts

    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')

  • #2
    Supreme Master coder! Old Pedant's Avatar
    Join Date
    Feb 2009
    Posts
    25,166
    Thanks
    75
    Thanked 4,338 Times in 4,304 Posts
    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?


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •