A
A
Andrey Sverlin2021-11-23 21:52:54
MySQL
Andrey Sverlin, 2021-11-23 21:52:54

How to write a query in MySQL to bulk edit the content of a specific TV field in MODX?

Hello.
Actually a site on MODX with a bunch of product positions. Each product has a TV field with a price. The price is written everywhere with a comma, and for two or three it turned out with a dot. It takes a very long time to search with pens, but you need to change the dot to a comma everywhere.

I am not at all familiar with SQL queries, but I realize that this task can (and probably should) be solved in this way. I would be very grateful for help.

I found this code, but I don't quite understand how to apply it in my case:

UPDATE Имя таблицы
SET Имя поля
REPLACE(Имя поля, 'строка для замены', 'чем заменяем');

Having dug into the database, I found a table with the content of TV fields - bsm_site_tmplvar_contentvalues
619d35f44c762964270449.jpeg
​​I.e. with "Table name" is clear, in my case it is necessary to write UPDATE bsm_site_tmplvar_contentvalues ​​(if I understood everything correctly).
But here with a name of a field it is not clear any more. The fields don't have names. There are columns... Specifically , the tmplvarid column shows the id of all TV fields. But I'm only interested in TV fields with id = 11 - these are the fields where prices are stored. And the replacement should be carried out only in them.

How can I correctly write a request for this replacement, and at the same time not break anything. Sykotno PPC. )))

Answer the question

In order to leave comments, you need to log in

1 answer(s)
D
Danny Arty, 2021-11-23
@imhateb

UPDATE bsm_site_tmplvar_contentvalues
SET value = REPLACE(value, '.', ',')
WHERE tmplvarid = 11

And of course, before each such operation, make a backup of the database

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question