SitePoint Sponsor

User Tag List

Results 1 to 4 of 4
  1. #1
    SitePoint Guru
    Join Date
    Sep 2008
    Location
    Dubai
    Posts
    971
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    should I use INSERT or UPDATE in this ?

    Hi,

    I have a table with 10 fields, 3 of them were filled in previous query, now I want to fill the rest fields, Should i use INSERT or UPDATE in my query ?

  2. #2
    SitePoint Evangelist
    Join Date
    Aug 2007
    Posts
    566
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Dude, they don't do the same....
    Insert is to inserting new rows.
    Update is to update rows that have already been inserted.
    You will have to use insert on the remaining rows, and update on the existing.

  3. #3
    SitePoint Addict wibble wobble's Avatar
    Join Date
    Dec 2008
    Posts
    242
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Think what tripy means is:

    Use an update query to fill in the 7 fields in the rows already in the database.
    Use an insert query to add new rows (with all fields, some of which could be null).
    Find freelance jobs from all the major sites in one place:
    on twitter / on the web / twitter rss feed

  4. #4
    SQL Consultant gold trophysilver trophybronze trophy
    r937's Avatar
    Join Date
    Jul 2002
    Location
    Toronto, Canada
    Posts
    39,276
    Mentioned
    60 Post(s)
    Tagged
    3 Thread(s)
    you could also use INSERT...ON DUPLICATE KEY UPDATE for all 10 entries
    rudy.ca | @rudydotca
    Buy my SitePoint book: Simply SQL
    "giving out my real stuffs"


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
  •