Results 1 to 2 of 2
  1. #1
    Join Date
    Nov 2011
    Posts
    1

    Unanswered: Using an update query to replace a string in the first 3 characters in a field

    EDIT: (I meant the first 2 characters in a field)

    I have a field [ALTCODE] containing SKU#s that look like :
    S4563-0-S
    S90908-S0
    S987-9S87

    I want to update the fields to look like :
    S-4563-0-S
    S-90908-S0
    S-987-9S87

    I looked around on the forums and couldn't find anything that would help me.

    I am an access noob...

    Thanks in advance!

  2. #2
    Join Date
    Nov 2004
    Location
    out on a limb
    Posts
    13,692
    Provided Answers: 59
    UPDATE mytable
    SET mycolumn = left(mycolumn,1,1) & "-" & mid(mycolumn,2)
    WHERE left(mycolumn,1) = "S"

    that updates the column by inserting a hyphen if the first character of mycolumn is a "S"

    you may want to try this out on copy of the live table
    or tinker with the query as a SELECT untill you are certain its returning the results you want


    SELECT mycolumn = left(mycolumn,1,1) & "-" & mid(mycolumn,2)
    WHERE left(mycolumn,1) = "S"
    I'd rather be riding on the Tiger 800 or the Norton

Posting Permissions

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