如何删除位于两个确切单词之间的列中的单词

时间:2017-08-07 05:29:02

标签: mysql database

在Mysql数据库表中,列的示例行如下所示,

/town=xxx/area=yyy/street=zzz/apartment_name=aaa/doorno=bbb

如何删除/ street /和/ doorno /之间的单词。所以我的预期输出应该显示在下面,

/town=xxx/area=yyy/street=zzz/doorno=bbb

1 个答案:

答案 0 :(得分:0)

MySQL提供了许多有用的String函数,例如LOCATE(),POSTION,SUBSTR,SUBSTRING等 请参阅:https://dev.mysql.com/doc/refman/5.7/en/string-functions.html

查询给定问题的解决方案:

选择concat((SELECT SUBSTRING_INDEX('/ town = xxx / area = yyy / street = zzz / apartment_name = aaa / doorno = bbb','/',4)),  (选择SUBSTR('/ town = xxx / area = yyy / street = zzz / apartment_name = aaa / doorno = bbb', (选择POSITION((选择SUBSTRING_INDEX('/ doorno','/',4))IN“/ town = xxx / area = yyy / street = zzz / apartment_name = aaa / doorno = bbb”)),100) ))