35 messages in com.mysql.lists.mysqlRE: Multi table update
FromSent OnAttachments
Michael J. Pawlowsky27 Dec 2004 19:16 
Curtis Maurand27 Dec 2004 21:42 
Kai Ruhnau28 Dec 2004 01:22 
SGr...@unimin.com28 Dec 2004 07:09 
Kai Ruhnau28 Dec 2004 07:09 
Jay Blanchard28 Dec 2004 07:21 
Kai Ruhnau28 Dec 2004 07:23 
SGr...@unimin.com28 Dec 2004 07:33 
SGr...@unimin.com28 Dec 2004 07:36 
Jay Blanchard28 Dec 2004 07:48 
Kai Ruhnau28 Dec 2004 08:06 
Jay Blanchard28 Dec 2004 08:38 
Curtis Maurand28 Dec 2004 09:52 
Curtis Maurand28 Dec 2004 10:11 
SGr...@unimin.com28 Dec 2004 10:23 
SGr...@unimin.com28 Dec 2004 10:48 
Kai Ruhnau28 Dec 2004 12:14 
Jay Blanchard29 Dec 2004 05:15 
Jay Blanchard29 Dec 2004 05:22 
Kai Ruhnau29 Dec 2004 14:45 
Jay Blanchard30 Dec 2004 04:59 
SGr...@unimin.com30 Dec 2004 07:49 
Kai Ruhnau30 Dec 2004 08:21 
Jay Blanchard30 Dec 2004 08:43 
Kai Ruhnau30 Dec 2004 09:48 
SGr...@unimin.com30 Dec 2004 10:01 
Jay Blanchard30 Dec 2004 10:19 
Jay Blanchard30 Dec 2004 10:31 
SGr...@unimin.com30 Dec 2004 11:41 
Jay Blanchard30 Dec 2004 12:50 
SGr...@unimin.com30 Dec 2004 14:00 
Jay Blanchard30 Dec 2004 14:20 
Jay Blanchard30 Dec 2004 14:21 
SGr...@unimin.com31 Dec 2004 07:28 
Jay Blanchard03 Jan 2005 05:40 
Subject:RE: Multi table update
From:Jay Blanchard (jay.@niicommunications.com)
Date:12/28/2004 08:38:36 AM
List:com.mysql.lists.mysql

[snip] And the query:

UPDATE table1 INNER JOIN table2 ON table2.ID_table1=table1.ID SET table2.value=table2.value-IF(table1.condition=7,1,0), table1.condition=8 WHERE table1.ID IN (1,2)

After that the value's in table2 are still 5 and 2. But I would expect the 5 to be a 4. [/snip]

It was concerning the warning I sent about InnoDB and the order of precedence.....the query to solve the problem is here....

update table2, table1 SET table2.value=table2.value-IF(table1.condition=7,1,0), table1.condition=8 WHERE table1.ID = table2.ID_table1

Note that you put table1 first in your query above, so table 1 will get updated first. Since that is the case the conditions for updating table2 are never met.