the task is to replace part of the data (varchar / datetime) contained in the cell with the string "***"; for example, the cell contains the last name "Petrov"; the request should return "P *** in" similarly with the date "03-11-2016" -> "03***16" What should the query look like? It is advisable for such purposes to use mysql, or is it more correct to process the data in the program code?

  • In principle, on the client, of course, it is easier to do this, for example, regularly. There is no special sense to do it right in the database, unless of course you need to write this modified information somewhere in the database. If in the database, then substr takes the first and last characters and between them *** insert - Mike

1 answer 1

I will not write a complete request, there is no mysql at hand to check, here is a look at http://www.mysql.ru/docs/man/String_functions.html

Use something like: UPDATE tableName SET first_name = REPLACE (first_name, SUBSTRING (..., 2, 4), '***')

the algorithm is simple, it is necessary to replace the cut string with *** it is better to do it on the side of the base, since if you have more than 1000000 entries, there is no point in loading this operation on the client, everything will be quickly executed in the database