I have 2 tables, which one of them is appen to other. I'm using opencart, and need to update title to all products from specific category.
Example: 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
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 );
This will help you.
If you have more then a product_id you should use where product_id in and not 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);
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.