V
V
Vlad2018-03-08 17:44:56
PHP
Vlad, 2018-03-08 17:44:56

How to do bulk replace in MySQL database?

Please tell me how to delete the content from the word "iframe" to the end in the product_description table in all fields containing the word "cincopa".

Answer the question

In order to leave comments, you need to log in

3 answer(s)
O
Orkhan Hasanli, 2018-03-08
@Sc0undRel

or just download the dump database.
open with notepad ++ or sulime and replace with regexp
it all depends on the database and the specific string...

R
Roman Mirilaczvili, 2018-03-08
@2ord

MySQL: INSTR + SUBSTRING + REPLACE + UPDATE ... WHERE ...

I
Immortal_pony, 2018-03-09
@Immortal_pony

Specify in more detail which columns you have in the product_description table.
For one column "text" it would be like this:

UPDATE `product_description`
SET `product_description`.`text`=LEFT(`product_description`.`text`, LOCATE('iframe', `product_description`.`text`)-1)
WHERE 1
  AND `product_description`.`text` LIKE '%cincopa%'
  AND `product_description`.`text` LIKE '%iframe%'

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question