我有两张桌子: order_detail和product_attribute。
我在product_attribute中有一个名为product_attribute的字段,我希望将值复制到order_detail中的f_fabricacion中。
id_product_attribute in product_attribute和product_attribute_id in order_details必须相同。
我试着做这个更新,但它不起作用。
UPDATE order_detail
SET f_fabricacion = SELECT a.available_date FROM a.product_attribute, b.b2_order_detail WHERE a.id_product_attribute = b.product_attribute_id我能做什么?
谢谢。
发布于 2016-02-04 09:27:44
尝尝这个
UPDATE order_detail o JOIN product_attribute p
ON p.id_product_attribute = o.product_attribute_id
SET o.f_fabricacion = p.available_date; 发布于 2016-02-04 09:28:37
你可以按下面的方式做-
UPDATE order_detail od
join product_attribute pa on pa.id_product_attribute = od.product_attribute_id
set od.f_fabricacion = pa.available_date;如果您只想用任何条件更新几行,请按以下方式使用-
UPDATE order_detail od
join product_attribute pa on pa.id_product_attribute = od.product_attribute_id
set od.f_fabricacion = pa.available_date
where column_name="value";https://stackoverflow.com/questions/35197009
复制相似问题