我想用另一个表两行的内容更新一个表的行。有没有比使用 2 别名 ( ) 锁定表更有效的方法new_data AS x & y
。
SET AUTOCOMMIT=0;
START TRANSACTION;
LOCK TABLES
1_products_speech WRITE,
new_data as x WRITE,
new_data as y WRITE;
UPDATE 1_products_speech
SET
v1 = (SELECT
data_blob
FROM
new_data as x
WHERE
id = 1),
v2 = (SELECT
data_blob
FROM
new_data as y
WHERE
id = 2)
WHERE
fk_products_id = 1890;
COMMIT;
UNLOCK TABLES;