SitePoint Sponsor

User Tag List

Results 1 to 3 of 3
  1. #1
    SitePoint Wizard Zaggs's Avatar
    Join Date
    Feb 2005
    Posts
    1,045
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Append value to the beginning of a field

    Hi Guys!

    I am trying to add a value to the beginning of a field in my database (there are over 20,000 rows, so it's impossible to do manually).

    I tried the following query, which added the value to the end of the field. Is there a way to add it to the beginning of a field like a prefix.

    PHP Code:
    update users set cv CONCAT(cv'uploads/users/cvs/'); 

  2. #2
    Non-Member
    Join Date
    Apr 2004
    Location
    Miami, FL, USA
    Posts
    449
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Code:
    update users set cv = CONCAT('uploads/users/cvs/', cv);

  3. #3
    Non-Member
    Join Date
    Apr 2004
    Location
    Miami, FL, USA
    Posts
    449
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    PS - when running an UPDATE like this, you should always first run it as a SELECT first to ensure you get the results you're looking for.... otherwise you may permanently screw up your DB!!!

    e.g.
    Code:
    SELECT CONCAT('uploads/users/cvs/', cv) FROM users;


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
  •