SitePoint Sponsor

User Tag List

Results 1 to 3 of 3

Hybrid View

  1. #1
    SitePoint Addict
    Join Date
    Sep 2004
    Location
    seattle
    Posts
    306
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    on duplicate key updating all fields

    i'm having a problem with this query. I have a table with 9 fields, but i only want to update 1 of the fields on duplicate key. For some reason it's updating all my fields..

    if ($OLD_DATA[register] = '0') {

    $sql = "INSERT INTO card (pc, forcexport)
    VALUES ('$NEWPC', '1') ON DUPLICATE KEY UPDATE forcexport='1'";
    }

  2. #2
    Utopia, Inc. silver trophy
    ScallioXTX's Avatar
    Join Date
    Aug 2008
    Location
    The Netherlands
    Posts
    9,067
    Mentioned
    153 Post(s)
    Tagged
    2 Thread(s)
    could you do a show create table and post the output ?

    PS. I'm not interested in the data in the table, only the structure
    Rémon - Hosting Advisor

    SitePoint forums will switch to Discourse soon! Make sure you're ready for it!

    Minimal Bookmarks Tree
    My Google Chrome extension: browsing bookmarks made easy

  3. #3
    SitePoint Addict
    Join Date
    Sep 2004
    Location
    seattle
    Posts
    306
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    CREATE TABLE `card` (
    `pc` int(8) NOT NULL,
    `active_date` date default NULL,
    `first` varchar(15) default NULL,
    `last` varchar(15) default NULL,
    `email` varchar(30) default NULL,
    `phone` varchar(11) default NULL,
    `register` tinyint(3) NOT NULL default '0',
    `NotesPublic` text,
    `NotesInternal` text,
    `transfered` varchar(255) default NULL,
    `forcexport` tinyint(4) default '0',
    PRIMARY KEY (`pc`)
    ) ENGINE=MyISAM DEFAULT CHARSET=latin1


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
  •