您可以使用
select substring_index(substring(mycol, instr(mycol, "=")+1), " ", 1)
获取等号后的第一个标记。
这将返回76767。
此方法分两步进行:
substring(mycol, instr(mycol, "=")+1)
返回从等号后面开始的字符串。
substring_index( xxx , " ", 1)
从通过“ ”分割的虚拟数组中获取第一个元素,因此返回xxx的第一个标记。
@frst和@scnd设置为分隔符。您要查找的术语位于@frst和@scnd之间。在这种情况下,它是 SET @frst:='YYY='; SET @scnd:=''; 如果要更新,则需要使用以下代码UPDATE tbl set my_col = SUBSTRING_INDEX(SUBSTRING(my_col , INSTR(my_col , @frst)+1), @scnd, 1) WHERE my_col LIKE '%@scnd%'; 或者如果要选择,则使用以下代码SELECT SUBSTRING_INDEX(SUBSTRING(my_col , INSTR(my_col , @frst)+1), @scnd, 1) from WHERE my_col LIKE '%@scnd%'; - kklepper如果你想要更新,请使用
UPDATE table_name SET column_name = REPLACE(column_name, '76767', '');
如果你想在你的数据库中用 bla bla bla 替换 76767,请使用以下代码:
UPDATE table_name SET column_name = REPLACE(column_name, '76767', 'bla bla bla');
bla bla bla YYY= bla bla bla吗? - Vishwanath Dalvi