Extracting Text between sub strings in MySQL

后端 未结 1 786
醉梦人生
醉梦人生 2021-01-24 21:40

I have a text like the below

[:de]

Die BB2 ist eine erlesene türkische Gulet in klassischer Holzbauweise, die alle Annehmlichkeiten und die Eleganz einer exklusiven

相关标签:
1条回答
  • 2021-01-24 22:40

    Assuming this is your data with the german always before the english, then:

    select substring_index(substring_index(col, '[:de]', -1), '[:en]', 1)
    

    If this is not the case, you can test for different possibilities:

    select (case when col like '%[:de]%[%:en]%'
                 then substring_index(substring_index(col, '[:de]', -1), '[:en]', 1)
                 when col like '%[:de]%[%:]%'
                 then substring_index(substring_index(col, '[:de]', -1), '[:]', 1)
                 else substring_index(col, '[:de]', -1)
           end)
    
    0 讨论(0)
提交回复
热议问题