MYSQL在“"之间选择多个值在列 [英] MYSQL SELECT multiple values between "" in Column

查看:37
本文介绍了MYSQL在“"之间选择多个值在列的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一列返回

a:2:{i:0;s:10:"Properties";i:1;s:14:"Movable Assets";}

我只想返回:

Properties, Movable Assets

如何使用 select 语句检索 " 符号之间的值

How can I use a select statement to retrieve the values between the " symbols

推荐答案

使用SUBSTRING_INDEX().

SUBSTRING_INDEX() 接受一个字符串参数,后跟一个分隔符和要返回的部分数.使用分隔符拆分字符串后,该部分数将作为单个字符串返回.

SUBSTRING_INDEX() takes a string argument followed by a delimiter character and the number of parts to return. After you break up the string using the delimiter, that number of parts is returned as a single string.

select concat( 
    SUBSTRING_INDEX( 
        SUBSTRING_INDEX( 
            SUBSTRING_INDEX( 
                'a:2:{i:0;s:10:"Properties";i:1;s:14:"Movable Assets";}',
                '"',
                4
            ),
            '"',
            2
        ),
        '"',
        -1
    ),
    ",",
    SUBSTRING_INDEX(
        SUBSTRING_INDEX( 
            SUBSTRING_INDEX(
                'a:2:{i:0;s:10:"Properties";i:1;s:14:"Movable Assets";}',
                '"',
                4
            ),
            '"',
            4
        ),
        '"',
        -1
    )
);

这篇关于MYSQL在“"之间选择多个值在列的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆