John
John

Reputation: 136

change prices in a specific category

I can change all the prices in all categories with the following command but I only want to change prices in a specific category but the category info is in another table called categories with a column called categories_id , the category id is 12, ho can I do it? thanks

UPDATE products SET products_price = REPLACE(products_price, "20","22")

Upvotes: 0

Views: 63

Answers (1)

kuma  DK
kuma DK

Reputation: 1861

Use where clause to restrict the rows effected

  WHERE cat="A"

ex->
  update products set price= replace(price,20,22) where cat="A"

you don't need to deal with the cat info table. Hope you have a foreign key field("cat") in main table that will map with the cat info table.

Upvotes: 1

Related Questions