在MYSQL中经常遇到连接查询,但是连接更新如何操作呢。下面给出一种标准连接更新的SQL
UPDATE tpc_custody_history t
INNER JOIN (
SELECT
id,
`custody_id`,
orig_amount
FROM
tpc_custody_history
WHERE
id IN (21815, 3373, 3358, 96)
) a ON t.custody_id = a.custody_id
SET t.amount = a.orig_amount,
t. COMMENT = '添加..'
WHERE
t. COMMENT = '添加.'
AND t.amount = 0
AND t.orig_amount = 0;