【问题标题】:Extract a str from a variable length link MYSQL从可变长度链接MYSQL中提取str
【发布时间】:2020-07-03 16:39:02
【问题描述】:

我找不到执行以下查询的方法。

给出一个链接:

/trips/oneway/type/2/f/**996**/t/**710**/d/**2020-04-22**/iR/0/l/es/p/1
OR    
/trips/oneway/type/2/f/**8890**/t/**9088**/d/**2020-06-10**/iR/1/c/**2020-06-17**/l/es/p/1

我需要提取粗体标记的str:这些是=在f//t/之间,

t//d/

之间的代码

介于 d//iR/ 之间。

我不能用 substring_index() 来做到这一点,因为索引会根据代码的长度而变化..

有人可以帮帮我吗!!??

谢谢!

【问题讨论】:

    标签: mysql sql database dbeaver


    【解决方案1】:

    假设这些代码在字符串中只有一次,你可以使用substring_index()

    substring_index(substring_index(url, 'f/', -1), '/t/', 1)
    substring_index(substring_index(url, 't/', -1), '/d/', 1)
    substring_index(substring_index(url, 'd/', -1), '/iR/', 1)
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2013-09-01
      • 2017-08-24
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2012-01-30
      相关资源
      最近更新 更多