At 12:38 -0700 on 05/27/2004, Daevid Vincent wrote about Re: Feature
Request: UPDATE 'error codes' or mysql_affected:
REPLACE INTO won't work, as I need the previous record (hence the update). I
store the first and last time I saw a node, amongst other info. REPLACE
would delete that data.
REPLAC
Daevid Vincent wrote:
Well, my "hack" (which is sort of like what you suggest) is to change my
primary key from just an auto_increment 'id' field to a combination of two
other fields (mac/scanner_id) that I know must be unique. Then I rely upon
the fact that mySQL will not allow a duplicate PK. (I
PLACE
would delete that data.
http://daevid.com
> -Original Message-
> From: Steve Meyers [mailto:[EMAIL PROTECTED]
> Sent: Thursday, May 27, 2004 7:42 AM
> To: Daevid Vincent
> Cc: [EMAIL PROTECTED]
> Subject: Re: Feature Request: UPDATE 'error codes' or
> mysql_a
http://dev.mysql.com/doc/mysql/en/INSERT.html
INSERT [LOW_PRIORITY | DELAYED] [IGNORE]
[INTO] tbl_name [(col_name,...)]
VALUES ({expr | DEFAULT},...),(...),...
[ ON DUPLICATE KEY UPDATE col_name=expr, ... ]
If you specify the ON DUPLICATE
Does REPLACE INTO not work in your case?
|
|
|REPLACE| works exactly like |INSERT|, except that if an old record
in the table has the same value as a new record for a |PRIMARY KEY|
or a |UNIQUE| index, the old record is deleted before the new record
is inserted. See section 14.1.4 |INSE
I'm developing a program where I try an "UPDATE ... LIMIT 1" and if
mysql_affected_rows == 0, then I know nothing was updated and so I do an
INSERT. I find this is much cleaner and the majority of the time, I'm going
to do UPDATES, so I didn't want to waste a SELECT (even though I hear
they're "che