2
2
2slide2017-08-17 12:52:25
MySQL
2slide, 2017-08-17 12:52:25

How to replace part of text in Sql table with query?

In the product table there is a description field in which you need to delete all "(MMLDS / RU)" models in brackets are always different. Delete along with parentheses.
Tried like this, but nothing comes out. If you explicitly specify the replacement string, then it works.

UPDATE product SET  `description` = REPLACE(  `description` , like'%(%)%',  '' )

Thank you.

Answer the question

In order to leave comments, you need to log in

2 answer(s)
R
Rsa97, 2017-08-17
@2slide

UPDATE `product`
  SET `description` = CONCAT(SUBSTRING_INDEX(`description`, '(', 1), SUBSTRING_INDEX(`description`, ')', -1)) 
  WHERE `description` LIKE '%(%)%'

D
Denis Holub, 2017-08-17
@denman1985

UPDATE product SET  `description` = 
CONCAT(  SUBSTR(`description`, 1, INSRT(`description`, '(')-1), 
         SUBSTR(`description`, INSRT(`description`,')')+1) )

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question