Copy Data from One Field to Another along with some Text ?

Discussion in 'MySQL' started by proprod, Dec 29, 2007.

  1. #1
    ok... I've been messing with this for a while and have gotten frustrated.

    Here is what I have in phpMyAdmin:

    UPDATE `TABLE` SET `FIELD2` = `FIELD1'
    Code (markup):
    Which basically copies all the entries in FIELD1 to FIELD2. That's great, now what if I want to place some text before and after? Example:

    UPDATE `TABLE` SET `FIELD2` = "Text before field data" `FIELD1' "text after field data"
    Code (markup):
    Does anyone know how to do this in phpmyadmin or do I have to use a php script to do this and if so, what's the code?

    I thank all of you in advance, this is driving me nuts :)
     
    proprod, Dec 29, 2007 IP
  2. Kuldeep1952

    Kuldeep1952 Active Member

    Messages:
    290
    Likes Received:
    18
    Best Answers:
    0
    Trophy Points:
    60
    #2
    use mysql concat function

    UPDATE `TABLE` SET `FIELD2` = concat("Text before field data", FIELD1 , "text after field data")
     
    Kuldeep1952, Dec 29, 2007 IP
    proprod likes this.
  3. proprod

    proprod Active Member

    Messages:
    216
    Likes Received:
    11
    Best Answers:
    0
    Trophy Points:
    90
    #3
    Excellent, kuldeep, that worked great, I really appreciate it!
     
    proprod, Dec 29, 2007 IP
  4. Shafiul

    Shafiul Peon

    Messages:
    55
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #4
    I want to do the job
     
    Shafiul, Feb 3, 2010 IP