SitePoint Sponsor

User Tag List

Results 1 to 5 of 5
  1. #1
    SitePoint Zealot
    Join Date
    Apr 2003
    Location
    canada
    Posts
    157
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)

    Post updating/appending to mysql

    Hello everybody,


    I need information or tutorial on appending data to existing field in a database.
    I looked up information on it but little confused.. is "updating" adding to the existing data or does it replace the existing data in a field.

    any ideas or site that can give me some ideas on how append to existing data would be greate...examples even better...

    Thanks everybody..
    Robin

  2. #2
    SitePoint Wizard
    Join Date
    Mar 2002
    Location
    Bristol, UK
    Posts
    2,240
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Updating replaces the existing data in a field.

    An UPDATE query would look something like:

    UPDATE table SET field = 'Somevalue', field2 = 'Anothervalue' WHERE condition;

    However this query will only change the values of the fields 'field' and 'field2'. Any other fields that exist in that table would remain unchanged.

    Hope this helps

    -Sam
    Sam Hastings

  3. #3
    SitePoint Zealot
    Join Date
    Apr 2003
    Location
    canada
    Posts
    157
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)
    Hi Devilware.net..
    I tried the statement and it replaced the content of the field insted of adding to the field..need somthing to append..

  4. #4
    SitePoint Member
    Join Date
    Feb 2003
    Location
    Melbourne, Australia
    Posts
    3
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    robin01, if you don't want to replace the data already in the database, then you should use INSERT rather than UPDATE.

    Insert will add a completely new row to the database with the provided data.

    If however, you want to append to the data already stored in the field you can use the concat() to do so (in MySQL at least):
    Code:
    UPDATE test SET name = concat("Mr. ",name) WHERE ID = 1
    That would add "Mr. " to the start of the name of the person with ID number 1.
    - Ethan

    Edit: had to fix my incredibly bad example
    Last edited by jobe; May 25, 2003 at 03:13.
    Counter Code Enterprise Edition
    Run your own web counter/statistics service

  5. #5
    SitePoint Enthusiast
    Join Date
    May 2003
    Location
    Serbia
    Posts
    53
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Althought widely used in php, this has nothing to do with php directly. It belongs to mysql forum
    Wondering about best weight loss pill? Take a look at Proactol.


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
  •