Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/url/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
在x之后但在y之前长度可变的MYSQL子字符串_Mysql_Url_Substring - Fatal编程技术网

在x之后但在y之前长度可变的MYSQL子字符串

在x之后但在y之前长度可变的MYSQL子字符串,mysql,url,substring,Mysql,Url,Substring,我是MYSQL的新手,使用PhpMyAdmin处理我的数据库 问题是,我有一个URL与常规的旧文本混合在一起,我正试图将其提取到其他地方使用。它并不总是相同的长度 SELECT SUBSTRING(description, LOCATE('X', description)+6) FROM table WHERE id=56; 这给了我X后面的所有内容 我需要的东西,可以拉出来之间的2个已知标识符的一切。 可能吗?请尝试以下操作: SELECT SUBSTRING_INDEX(SUBSTRIN

我是MYSQL的新手,使用PhpMyAdmin处理我的数据库

问题是,我有一个URL与常规的旧文本混合在一起,我正试图将其提取到其他地方使用。它并不总是相同的长度

SELECT
 SUBSTRING(description, LOCATE('X', description)+6)
FROM table WHERE id=56;
这给了我X后面的所有内容

我需要的东西,可以拉出来之间的2个已知标识符的一切。 可能吗?

请尝试以下操作:

SELECT SUBSTRING_INDEX(SUBSTRING(description, LOCATE('X', description)+6), Y, 1)
FROM table
WHERE id=56;
根据MySQL手册:

SUBSTRING_INDEX(str,delim,count) Returns the substring from string str before count occurrences of the delimiter delim. If count is positive, everything to the left of the final delimiter (counting from the left) is returned. If count is negative, everything to the right of the final delimiter (counting from the right) is returned. SUBSTRING_INDEX() performs a case-sensitive match when searching for delim.

你到底需要什么?如果描述是“jjksdj'dfld'dfdfdf'”,那么您的预期结果应该是什么。哇!太棒了!非常感谢。Y后面的数字1表示什么?有正数吗?很高兴我能帮忙。我在回答中添加了一个关于子字符串索引函数的解释。