有一张table:
| id | Name |
|----------------------|
| 1 |test1 test1 test1|
| 2 |test2 test2 test2|
想要选择第一个regex组(使用第一个单词来简化),所以我的查询:
SELECT regexp_replace(name, "^([[:alnum:]]+)[[:space:]].*$","$1") FROM table;
结果:
|test1 |
|test1test2 |
那么结果是如何累积的呢?如何避免它,仍然能够使用正则表达式组?
upd:mysql版本:8.0.11,mysql社区服务器-gpl
1条答案
按热度按时间acruukt91#
https://bugs.mysql.com/bug.php?id=90803 -5月21日:
已在8.0.12中修复。
regexp\u relace()来自一个结果集行的结果可能会结转到下一行,从而导致当前行中以前的结果的累积。