List:General Discussion« Previous MessageNext Message »
From:Philip Hallstrom Date:April 28 2007 2:12am
Subject:Re: INSERT ... ON DUPLICATE KEY UPDATE seems so close and yet so
far...
View as plain text  
> Maybe this is some SQL standard implementation and that's why it is what it
> is, but to me it seems completely retarded that you have to explicitly call
> out the columns...
>
> http://dev.mysql.com/doc/refman/5.0/en/insert-on-duplicate.html
>
> Why doesn't it work in a more convenient and sane way?!
>
> So instead of this cumbersome incantation that makes you want to rip out
> your hair and puch your cube-mate dead in the nose:
>
> insert into table1 (c1,c2,c3) values (v1,v2,v3) on duplicate key
> update c1=v1, c2=v2, c3=v3;
>
> Just allow a more sane and logical:
>
> insert into table1 (c1,c2,c3) values (v1,v2,v3) on duplicate key update;

Because if you wanted that you'd use REPLACE which is mysql specific which 
is okay since it's mysql you're using I guess.

And in my case, I have a stats table... I either want to insert a row with 
hits=1 or I want to hits=hits+1.  So I need to specify what I want.  And I 
don't want to change *any* of the other columns (such as the date for the 
hit or the id, etc.)

ANyway... not saying they couldn't do it both ways, but there is a reason.
Thread
UPDATE and INSERT in onelists20 Apr
  • Re: UPDATE and INSERT in oneJohan Höök20 Apr
    • INSERT ... ON DUPLICATE KEY UPDATE seems so close and yet so far...Daevid Vincent28 Apr
      • Re: INSERT ... ON DUPLICATE KEY UPDATE seems so close and yet sofar...Philip Hallstrom28 Apr
        • RE: INSERT ... ON DUPLICATE KEY UPDATE seems so close and yet so far...Daevid Vincent30 Apr
  • Re: UPDATE and INSERT in oneDavid Precious20 Apr
Re: UPDATE and INSERT in onewang shuming20 Apr