From: Michael Dykman Date: July 26 2009 5:17pm Subject: Re: Update Syntax List-Archive: http://lists.mysql.com/mysql/218285 Message-Id: <814b9a820907261017j7e0a7945vaed09ffddf507ded@mail.gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset=windows-1252 Content-Transfer-Encoding: quoted-printable 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=3D{expr | DEFAULT}, ... [ ON DUPLICATE KEY UPDATE col_name=3Dexpr [, col_name=3Dexpr] ... ] 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 =3D val1, ... ON DUPLIATE KEY UPDATE - michael dykman On Sun, Jul 26, 2009 at 1:11 PM, Victor Subervi wr= ote: > Hi; > I would like to test the following: > > update maps set map where site=3Dmysite; > > to see if there is such an entry in maps. If there is, then update. If th= ere > is not, then I would like to execute an insert statement. How do I do tha= t? > TIA, > Victor > --=20 - michael dykman - mdykman@stripped Don=92t worry about people stealing your ideas. If they=92re any good, you=92ll have to ram them down their throats! Howard Aiken