[英]Update specific column equal to other table
I have 2 tables, which one of them is appen to other.我有 2 个表,其中一个附加到另一个表。 I'm using opencart, and need to update title to all products from specific category.
我正在使用 opencart,需要更新特定类别中所有产品的标题。
Example: oc_product_description示例: oc_product_description
product_id
language_id
name
1
3
T-backs model 887 Róża
2
3
T-backs model 912 Róża
3
3
Push up model 3173 Róża
oc_product_to_category oc_product_to_category
category_id
product_id
1
1
2
1
3
1
And I can't imagine what query I should use..而且我无法想象我应该使用什么查询..
UPDATE oc_product_description
SET name = REPLACE(name, 'T-backs model', 'BACK')
WHERE product_id = SELECT product_id FROM oc_product_to_category WHERE category_id = 54;
UPDATE oc_product_description SET name = REPLACE(name, 'T-backs model', 'BACK') WHERE product_id IN ( SELECT product_id FROM oc_product_to_category WHERE category_id = 54 );更新 oc_product_description SET name = REPLACE(name, 'T-backs model', 'BACK') WHERE product_id IN ( SELECT product_id FROM oc_product_to_category WHERE category_id = 54 );
This will help you.这会帮助你。
If you have more then a product_id you should use where product_id in and not where product_id =如果你有更多的 product_id 你应该使用 where product_id in 而不是 where product_id =
UPDATE oc_product_description
SET name = REPLACE(name, 'T-backs model', 'BACK')
WHERE product_id in ( SELECT product_id
FROM oc_product_to_category WHERE category_id = 54);
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.