SitePoint Sponsor

User Tag List

Results 1 to 3 of 3

Thread: Update Data

  1. #1
    Weird Little Girl Desdelena's Avatar
    Join Date
    May 2002
    Location
    Canada
    Posts
    266
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Update Data

    OK lets say Ive got a table called "books", which has two columns being "author" and "title". I add "the fellowship of the ring" to title and "unknown" as the author. Then after I read the cover of the book I and see the authors name I was to completely replace what I have in the author space now, being "unknown", with "j.r.r. tolkien". Whats the command to do it? Im a newbie here... so if your going to do something crazy like theyve got at MYSQL.com can you provide an example and explain a little? Thanks ahead of time!
    Memento Mori

  2. #2
    SitePoint Addict -TheDarkEye-'s Avatar
    Join Date
    Feb 2001
    Location
    canada
    Posts
    286
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Code:
    UPDATE books
    SET    author = 'j.r.r. tolkien'
    WHERE  title = 'the fellowship of the ring'
    if i where you, i would set the books table up so that i could reffer to the books by a numeric id instead of the title. My reasoning for this is as follows:

    'the fellowship of the ring' != 'The Fellowship of The Ring'

    i hope you can see why this could cause you trouble.

  3. #3
    Weird Little Girl Desdelena's Avatar
    Join Date
    May 2002
    Location
    Canada
    Posts
    266
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Thanks DarkEye. That was just an example that was short to type out. In my database I actually have them all setup with unique IDs, so it should be no problem.
    Memento Mori


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
  •