Reputation: 37
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;
Upvotes: 1
Views: 74
Reputation: 411
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.
Upvotes: 1
Reputation: 133360
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);
Upvotes: 0