Andre,
I tried this a couple weeks ago... I think you want the on duplicate
option for the INSERT query.
depends what version you have... I think this was introduced in mysql 4.1
insert into values () on duplicate key update set x=2,y=5;
unfortunately, the server I was testing this
No George. I took a look there before sent this email to the mysql list. My
case it is not a duplicate record. What I want is that if the update in one
table happen, it will be proceed by an insert in another table like a log of
changes.
Andre
On 2/11/06 12:48 PM, George Law [EMAIL PROTECTED]
---
-Original Message-
From: Andre Matos [mailto:[EMAIL PROTECTED]
Sent: Sunday, 12 February 2006 2:23 PM
To: George Law; mysql@lists.mysql.com
Subject: Re: Insert and Update together
No George. I took a look there before sent this email
@lists.mysql.com
Subject: Re: Insert if Update failed without Select
[EMAIL PROTECTED] wrote:
Please also note hat UPDATE returns the number of records updated. If
your
UPDATE returns 0, you know that the record does not exist, and you
might
want to INSERT instead.
There is one situation
Please also note hat UPDATE returns the number of records updated. If your
UPDATE returns 0, you know that the record does not exist, and you might
want to INSERT instead.
There is one situation where the number of records updated will return
0, yet the row exists. If you update the record
[EMAIL PROTECTED] wrote:
Please also note hat UPDATE returns the number of records updated. If your
UPDATE returns 0, you know that the record does not exist, and you might
want to INSERT instead.
There is one situation where the number of records updated will return
0, yet the row exists.
At 2005-01-15 14:48, you wrote:
Without using Select statement, how can I execute Insert SQL statement if
Update action is failed?
I may be asking for too much. If Select statemnet have to be used to
determine the existence of a recordset, what is an efficient way to
execute Insert if Update is
Please also note hat UPDATE returns the number of records updated. If your
UPDATE returns 0, you know that the record does not exist, and you might
want to INSERT instead.
At 2005-01-15 14:54, you wrote:
At 2005-01-15 14:48, you wrote:
Without using Select statement, how can I execute Insert
* Joel Wickard
I need to write a query that will insert data into a table if there is no
row matching a pre-specified ID, but will update a row if it matches a
pre-specified ID.
Any pointers would be great.
The REPLACE statement:
URL: http://www.mysql.com/doc/R/E/REPLACE.html
--
Roger