SitePoint Sponsor

User Tag List

Results 1 to 5 of 5
  1. #1
    *********! *********!!! jackli's Avatar
    Join Date
    Sep 2005
    Posts
    436
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    mysql update append?

    is there a way to directly append in a single mysql update query? -- without first fetching the data?

  2. #2
    An average geek earl-grey's Avatar
    Join Date
    Mar 2005
    Location
    Ukraine
    Posts
    1,403
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Can you explain more detailly, please?

  3. #3
    Follow Me On Twitter: @djg gold trophysilver trophybronze trophy Dan Grossman's Avatar
    Join Date
    Aug 2000
    Location
    Philadephia, PA
    Posts
    20,580
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by jackli View Post
    is there a way to directly append in a single mysql update query? -- without first fetching the data?
    Yes...CONCAT for strings, DATE_ADD/DATE_SUB for dates, straight arithmetic operators for numbers. You can even do conditional logic within queries.

  4. #4
    SitePoint Guru
    Join Date
    Jul 2005
    Location
    Orlando
    Posts
    634
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by Dan Grossman View Post
    Yes...CONCAT for strings, DATE_ADD/DATE_SUB for dates, straight arithmetic operators for numbers. You can even do conditional logic within queries.
    As an example..

    UPDATE table SET field = CONCAT( field, ' this is appended' ) WHERE id = 7;

  5. #5
    *********! *********!!! jackli's Avatar
    Join Date
    Sep 2005
    Posts
    436
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    ... like magic... ok, now to replace all my mysql_fetch, concat in php, mysql_send code with the wonderful concat() function


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
  •