MySQL substring between two strings(两个字符串之间的 MySQL 子字符串)
问题描述
我需要帮助解决我的列字段的问题.我需要在这两个不同的字符串模式"之间提取字符串,例如:
I need a hand to solve a problem with my column field. I need to extract the string in between these two different "patterns" of strings for example:
[...string] 合约 = 1234567890123350566076070666 发出 = [string]...]
[...string] contract= 1234567890123350566076070666 issued= [string ...]
我想提取 'contract=' 和 'issued=' 之间的字符串
I want to extract the string in between 'contract=' and 'issued='
目前我正在使用
SELECT substring(substring_index(licence_key,'contract=',-1),1,40) FROM table
问题是中间的这个字符串并不总是有 40 个字符,所以它不是固定长度,所以它之前和之后的数据.这是一个不稳定的数据.
The problem is that this string in between doesn't have always 40 characters so it's not fixed length and so the data that comes before and after that. It's a volatile data.
你知道我怎么处理吗?
推荐答案
只需使用 substring_index()
两次:
SELECT substring_index(substring_index(licence_key, 'contract=', -1),
'issued=', 1)
FROM table;
这篇关于两个字符串之间的 MySQL 子字符串的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:两个字符串之间的 MySQL 子字符串


基础教程推荐
- 如何在 CakePHP 3 中实现 INSERT ON DUPLICATE KEY UPDATE aka upsert? 2021-01-01
- 从字符串 TSQL 中获取数字 2021-01-01
- CHECKSUM 和 CHECKSUM_AGG:算法是什么? 2021-01-01
- MySQL根据从其他列分组的值,对两列之间的值进行求和 2022-01-01
- 带更新的 sqlite CTE 2022-01-01
- ORA-01830:日期格式图片在转换整个输入字符串之前结束/选择日期查询的总和 2021-01-01
- while 在触发器内循环以遍历 sql 中表的所有列 2022-01-01
- MySQL 5.7参照时间戳生成日期列 2022-01-01
- 使用 VBS 和注册表来确定安装了哪个版本和 32 位 2021-01-01
- 带有WHERE子句的LAG()函数 2022-01-01