Need quick help. I know it may be easy, but can't find out how to do it.

Discussion in 'Databases' started by jfontestad, Jun 25, 2006.

  1. #1
    I want to add text to a specific column in a specific table. I want the text to be added to the end of the current data for each row in that column for that table.

    Ex: I want to add 'J Fontestad' to the end of every row in the column 'from' and table 'gone'.

    How would I do that? What would be the SQL command?

    Thanks.
     
    jfontestad, Jun 25, 2006 IP
  2. sadcox66

    sadcox66 Spirit Walker

    Messages:
    496
    Likes Received:
    16
    Best Answers:
    0
    Trophy Points:
    0
    #2
    Try a subselect if your database supports it. Something like

    Update Table1 set AColumn ( (Select AColumn from Table1) || 'J Fontestad' )
     
    sadcox66, Jun 25, 2006 IP
  3. jfontestad

    jfontestad Well-Known Member

    Messages:
    1,236
    Likes Received:
    20
    Best Answers:
    0
    Trophy Points:
    148
    #3
    That didn't work. I received an error on line 1.

    I substituted table1 and acolumn for my own of course and it didn't work. Any other suggestions ?
     
    jfontestad, Jun 25, 2006 IP
  4. iconv

    iconv Well-Known Member

    Messages:
    189
    Likes Received:
    3
    Best Answers:
    0
    Trophy Points:
    108
    #4
    UPDATE gone SET from = CONCAT(from, ' J Fontestad');
     
    iconv, Jun 25, 2006 IP
  5. jfontestad

    jfontestad Well-Known Member

    Messages:
    1,236
    Likes Received:
    20
    Best Answers:
    0
    Trophy Points:
    148
    #5
    That did the job.

    Thanks.
     
    jfontestad, Jun 26, 2006 IP