Marco Marco - 7 months ago 31
SQL Question

SQL UPDATE query with JOIN

I already search and real all previous questions & answers about it but i just can't find the good way to do what i want, so maybe my problem can also help other people, let see.

I'm trying to use this SQL query :

UPDATE L

SET L.description = REPLACE(L.description, '196,99', '197')

FROM ps_product_lang AS L
JOIN ps_product AS P
ON L.id_product = P.id_product



WHERE P.id_category_default = 23


to replace a string in ps_product_lang table, column description

The WHERE clause have to match an ID from ps_product table (column id_category_default)

What is wrong here?

Answer
UPDATE ps_product_lang AS L 

  JOIN ps_product AS P 
    ON L.id_product = P.id_product

   SET L.description = REPLACE(L.description, '196,99', '197') 

 WHERE P.id_category_default = 23
Comments