List:General Discussion« Previous MessageNext Message »
From:Michael Dykman Date:July 26 2009 5:17pm
Subject:Re: Update Syntax
View as plain text  
from: http://dev.mysql.com/doc/refman/5.1/en/insert.html:

INSERT [LOW_PRIORITY | DELAYED | HIGH_PRIORITY] [IGNORE]
    [INTO] tbl_name
    SET col_name={expr | DEFAULT}, ...
    [ ON DUPLICATE KEY UPDATE
      col_name=expr
        [, col_name=expr] ... ]


The ON DUPLICATE KEY predicate tells you that if you create a unique
key for when ever your 'search' criteria is, you can get this
behaviour like so:

INSERT INTO mytable SET col1 = val1, ...  ON DUPLIATE KEY UPDATE

 - michael dykman

On Sun, Jul 26, 2009 at 1:11 PM, Victor Subervi<victorsubervi@stripped> wrote:
> Hi;
> I would like to test the following:
>
> update maps set map where site=mysite;
>
> to see if there is such an entry in maps. If there is, then update. If there
> is not, then I would like to execute an insert statement. How do I do that?
> TIA,
> Victor
>



-- 
 - michael dykman
 - mdykman@stripped

Don’t worry about people stealing your ideas. If they’re any good,
you’ll have to ram them down their throats!

   Howard Aiken
Thread
Update SyntaxVictor Subervi26 Jul
  • Re: Update SyntaxMichael Dykman26 Jul
  • Re: Update SyntaxDarryle Steplight26 Jul
    • Re: Update SyntaxVictor Subervi26 Jul