Page 1 of 1

replace with auto increment

Posted: Tue Sep 05, 2006 10:25 am
by GeXus
This won't work will it? or how would you use replace if you are using autoincrement... this is to use one form that updates and inserts...

Posted: Tue Sep 05, 2006 10:41 am
by Luke
Image

Posted: Tue Sep 05, 2006 10:43 am
by GeXus
doesnt replace check to see if there is a duplicate primary key.. if so update, if not insert.. well if the primary key is auto incremented, it would never be duplicate..

I never use replace for this type of thing, but i just thought it could be cleaner if it would work, but maybe im way off.

Posted: Tue Sep 05, 2006 1:43 pm
by feyd
Try it.

Posted: Tue Sep 05, 2006 2:05 pm
by volka
http://dev.mysql.com/doc/refman/5.1/en/replace.html wrote:REPLACE works exactly like INSERT, except that if an old row in the table has the same value as a new row for a PRIMARY KEY or a UNIQUE index, the old row is deleted before the new row is inserted. See Section 13.2.4, “INSERT Syntax”.
and it's exactly that: delete & insert.