MySQL 更新多个具有相同值的字段

Sup*_*key 6 mysql

我在两个单独的表中有两个字段需要更新为相同的值。没有过程等。这可以在单个查询中实现吗?

工作声明:

UPDATE product,product_shop SET
 product_shop.price='737.96',
 product.price='737.96',
 product_shop.wholesale_price='479.67',
 product.wholesale_price='479.67'
WHERE 
 product_shop.id_product=product.id_product AND
 product_shop.id_product=14;
Run Code Online (Sandbox Code Playgroud)

我所希望的:

UPDATE product,product_shop SET
 product_shop.price=product.price='737.96',
 product_shop.wholesale_price=product.wholesale_price='479.67'
WHERE 
 product_shop.id_product=product.id_product AND
 product_shop.id_product=14;
Run Code Online (Sandbox Code Playgroud)

jfx*_*nja 7

MySQL 文档声明您可以执行此操作,如果您试图避免打印该值两次,您可以执行以下操作:

UPDATE product,product_shop SET
 product_shop.price='737.96',
 product.price=product_shop.price, 
 product_shop.wholesale_price='479.67',
 product.wholesale_price=product_shop.wholesale_price
WHERE 
 product_shop.id_product=product.id_product AND
 product_shop.id_product=14;
Run Code Online (Sandbox Code Playgroud)


d'a*_*cop 3

不。您的“工作查询”是您能做的最好的事情。