Search for text between delimiters in MySQL

前端 未结 11 2419
情歌与酒
情歌与酒 2021-02-08 03:39

I am trying to extract a certain part of a column that is between delimiters.

e.g. find foo in the following

test \'esf :foo: bar

So in the above I\'d wa

11条回答
  •  难免孤独
    2021-02-08 03:55

    you can use the substring / locate function in 1 command

    here is a mice tutorial:

    http://infofreund.de/mysql-select-substring-2-different-delimiters/

    The command as describes their should look for u:

    **SELECT substr(text,Locate(' :', text )+2,Locate(': ', text )-(Locate(' :', text )+2)) FROM testtable**

    where text is the textfield which contains "test 'esf :foo: bar"

    So foo can be fooooo or fo - the length doesnt matter :).

提交回复
热议问题