Scott,
This may work for you:
UPDATE
tableName
SET
bounce_count = bounce_count +1,
status = 'bounced_out'
WHERE
(bounce_count + 1) > 10;
UPDATE
tableName
SET
bounce_count = bounce_count + 1
WHERE
status <> 'bounced_out'
AND (bounce_count + 1) <= 10;
You might want to lock the table while you run those to ensure that nothing
else is breaking the atomicity of the queries. If you are using InnoDB you
would wrap it in a transaction.
Lachlan
-----Original Message-----
From: Scott Haneda [mailto:[EMAIL PROTECTED]
Sent: Wednesday, 11 August 2004 8:28 AM
To: MySql
Subject: Update on condition
I need to do a certain update based on a condition:
MySql4
Update table set bounce_count = bounce_count+1 is the basic query, somewhere
in there I need to only do a if bounce_count+1 > 10 then update status =
'bounced_out'
--
-------------------------------------------------------------
Scott Haneda Tel: 415.898.2602
http://www.newgeo.com Fax: 313.557.5052
[EMAIL PROTECTED] Novato, CA U.S.A.
--
MySQL General Mailing List
For list archives: http://lists.mysql.com/mysql
To unsubscribe: http://lists.mysql.com/[EMAIL PROTECTED]
--
MySQL General Mailing List
For list archives: http://lists.mysql.com/mysql
To unsubscribe: http://lists.mysql.com/[EMAIL PROTECTED]