SitePoint Sponsor

User Tag List

Results 1 to 3 of 3
  1. #1
    SitePoint Member
    Join Date
    Apr 2013
    Posts
    11
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Insert some text after last character in a SQL string

    Hi,
    I have a table like this:

    id | name
    +++++++++
    1 | ab
    2 | bq
    3 | g
    4 | qaa
    5 | e

    I'd like to add "11" after the last character for each row in a column. So I need it to be:

    id | name
    +++++++++
    1 | ab11
    2 | bq11
    3 | g11
    4 | qaa11
    5 | e11

    I tried: "UPDATE table SET name=name+'11' , but that doesnt work.

    Is there a way to accomplish this?

  2. #2
    SitePoint Member
    Join Date
    Apr 2013
    Posts
    11
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Ah, I have done it when i try UPDATE TABLE SET name =concat(name, '11').

  3. #3
    SQL Consultant gold trophysilver trophybronze trophy
    r937's Avatar
    Join Date
    Jul 2002
    Location
    Toronto, Canada
    Posts
    39,341
    Mentioned
    63 Post(s)
    Tagged
    3 Thread(s)
    name+'11' is sql server syntax, concat(name,'11') is mysql syntax

    you need to tell us which database you're using when you ask a question

    rudy.ca | @rudydotca
    Buy my SitePoint book: Simply SQL
    "giving out my real stuffs"


Bookmarks

Posting Permissions

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