Description:
REGEXP_REPLACE function truncates the result when performing an UPDATE.
How to repeat:
mysql> SELECT VERSION();
+-----------+
| VERSION() |
+-----------+
| 8.0.11 |
+-----------+
1 row in set (0.00 sec)
mysql> DROP TABLE IF EXISTS `test`;
Query OK, 0 rows affected (0.42 sec)
mysql> CREATE TABLE IF NOT EXISTS `test` (
-> `field` CHAR(6)
-> );
Query OK, 0 rows affected (0.56 sec)
mysql> INSERT INTO `test` (`field`)
-> VALUES ('567890');
Query OK, 1 row affected (0.08 sec)
mysql> SELECT REGEXP_REPLACE(`field`, '[7]', 'z')
-> FROM `test`;
+-------------------------------------+
| REGEXP_REPLACE(`field`, '[7]', 'z') |
+-------------------------------------+
| 56z890 |
+-------------------------------------+
1 row in set (0.00 sec)
mysql> SELECT `field`
-> FROM `test`;
+--------+
| field |
+--------+
| 567890 |
+--------+
1 row in set (0.00 sec)
mysql> UPDATE `test`
-> SET `field` = REGEXP_REPLACE(`field`, '[7]', 'z');
Query OK, 1 row affected (0.07 sec)
Rows matched: 1 Changed: 1 Warnings: 0
mysql> SELECT `field`
-> FROM `test`;
+-------+
| field |
+-------+
| 56 |
+-------+
1 row in set (0.11 sec)
See Stack Overflow question: mysql regexp_replace with update - https://stackoverflow.com/questions/50309333/mysql-regexp-replace-with-update
Description: REGEXP_REPLACE function truncates the result when performing an UPDATE. How to repeat: mysql> SELECT VERSION(); +-----------+ | VERSION() | +-----------+ | 8.0.11 | +-----------+ 1 row in set (0.00 sec) mysql> DROP TABLE IF EXISTS `test`; Query OK, 0 rows affected (0.42 sec) mysql> CREATE TABLE IF NOT EXISTS `test` ( -> `field` CHAR(6) -> ); Query OK, 0 rows affected (0.56 sec) mysql> INSERT INTO `test` (`field`) -> VALUES ('567890'); Query OK, 1 row affected (0.08 sec) mysql> SELECT REGEXP_REPLACE(`field`, '[7]', 'z') -> FROM `test`; +-------------------------------------+ | REGEXP_REPLACE(`field`, '[7]', 'z') | +-------------------------------------+ | 56z890 | +-------------------------------------+ 1 row in set (0.00 sec) mysql> SELECT `field` -> FROM `test`; +--------+ | field | +--------+ | 567890 | +--------+ 1 row in set (0.00 sec) mysql> UPDATE `test` -> SET `field` = REGEXP_REPLACE(`field`, '[7]', 'z'); Query OK, 1 row affected (0.07 sec) Rows matched: 1 Changed: 1 Warnings: 0 mysql> SELECT `field` -> FROM `test`; +-------+ | field | +-------+ | 56 | +-------+ 1 row in set (0.11 sec) See Stack Overflow question: mysql regexp_replace with update - https://stackoverflow.com/questions/50309333/mysql-regexp-replace-with-update