1. <i id='PqHOv'><tr id='PqHOv'><dt id='PqHOv'><q id='PqHOv'><span id='PqHOv'><b id='PqHOv'><form id='PqHOv'><ins id='PqHOv'></ins><ul id='PqHOv'></ul><sub id='PqHOv'></sub></form><legend id='PqHOv'></legend><bdo id='PqHOv'><pre id='PqHOv'><center id='PqHOv'></center></pre></bdo></b><th id='PqHOv'></th></span></q></dt></tr></i><div id='PqHOv'><tfoot id='PqHOv'></tfoot><dl id='PqHOv'><fieldset id='PqHOv'></fieldset></dl></div>

        <bdo id='PqHOv'></bdo><ul id='PqHOv'></ul>
      <tfoot id='PqHOv'></tfoot>

      <small id='PqHOv'></small><noframes id='PqHOv'>

      <legend id='PqHOv'><style id='PqHOv'><dir id='PqHOv'><q id='PqHOv'></q></dir></style></legend>

      使用分隔符提取 MySQL 子串

      MySQL substring extraction using delimiter(使用分隔符提取 MySQL 子串)

      <legend id='30QQA'><style id='30QQA'><dir id='30QQA'><q id='30QQA'></q></dir></style></legend><tfoot id='30QQA'></tfoot>
          <bdo id='30QQA'></bdo><ul id='30QQA'></ul>
            <tbody id='30QQA'></tbody>

              • <small id='30QQA'></small><noframes id='30QQA'>

              • <i id='30QQA'><tr id='30QQA'><dt id='30QQA'><q id='30QQA'><span id='30QQA'><b id='30QQA'><form id='30QQA'><ins id='30QQA'></ins><ul id='30QQA'></ul><sub id='30QQA'></sub></form><legend id='30QQA'></legend><bdo id='30QQA'><pre id='30QQA'><center id='30QQA'></center></pre></bdo></b><th id='30QQA'></th></span></q></dt></tr></i><div id='30QQA'><tfoot id='30QQA'></tfoot><dl id='30QQA'><fieldset id='30QQA'></fieldset></dl></div>
                本文介绍了使用分隔符提取 MySQL 子串的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                问题描述

                限时送ChatGPT账号..

                我想从 MySQL 中的字符串中提取子字符串.该字符串包含多个由逗号(',')分隔的子字符串.我需要使用任何 MySQL 函数提取这些子字符串.

                I want to extract the substrings from a string in MySQL. The string contains multiple substrings separated by commas(','). I need to extract these substrings using any MySQL functions.

                例如:

                Table Name: Product
                -----------------------------------
                item_code  name    colors
                -----------------------------------
                102        ball     red,yellow,green
                104        balloon  yellow,orange,red  
                

                我想选择颜色字段并将子字符串提取为以逗号分隔的红色、黄色和绿色.

                I want to select the colors field and extract the substrings as red, yellow and green as separated by comma.

                推荐答案

                可能与此重复:将值从一个字段拆分为两个

                不幸的是,MySQL 没有拆分字符串功能.如上面的链接所示,有用户定义的拆分函数.

                Unfortunately, MySQL does not feature a split string function. As in the link above indicates there are User-defined Split function.

                获取数据的更详细的版本如下:

                A more verbose version to fetch the data can be the following:

                SELECT SUBSTRING_INDEX(SUBSTRING_INDEX(colors, ',', 1), ',', -1) as colorfirst,
                       SUBSTRING_INDEX(SUBSTRING_INDEX(colors, ',', 2), ',', -1) as colorsecond
                ....
                       SUBSTRING_INDEX(SUBSTRING_INDEX(colors, ',', n), ',', -1) as colornth
                  FROM product;
                

                这篇关于使用分隔符提取 MySQL 子串的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                本站部分内容来源互联网,如果有图片或者内容侵犯了您的权益,请联系我们,我们会在确认后第一时间进行删除!

                相关文档推荐

                ibtmp1是非压缩的innodb临时表的独立表空间,通过innodb_temp_data_file_path参数指定文件的路径,文件名和大小,默认配置为ibtmp1:12M:autoextend,也就是说在文件系统磁盘足够的情况下,这个文件大小是可以无限增长的。 为了避免ibtmp1文件无止境的暴涨导致
                What does SQL clause quot;GROUP BY 1quot; mean?(SQL 子句“GROUP BY 1是什么意思?意思是?)
                MySQL groupwise MAX() returns unexpected results(MySQL groupwise MAX() 返回意外结果)
                MySQL SELECT most frequent by group(MySQL SELECT 按组最频繁)
                Why Mysql#39;s Group By and Oracle#39;s Group by behaviours are different(为什么 Mysql 的 Group By 和 Oracle 的 Group by 行为不同)
                MySQL GROUP BY DateTime +/- 3 seconds(MySQL GROUP BY DateTime +/- 3 秒)

                <small id='8tuiM'></small><noframes id='8tuiM'>

                  <tbody id='8tuiM'></tbody>

                    • <bdo id='8tuiM'></bdo><ul id='8tuiM'></ul>
                    • <legend id='8tuiM'><style id='8tuiM'><dir id='8tuiM'><q id='8tuiM'></q></dir></style></legend><tfoot id='8tuiM'></tfoot>
                      1. <i id='8tuiM'><tr id='8tuiM'><dt id='8tuiM'><q id='8tuiM'><span id='8tuiM'><b id='8tuiM'><form id='8tuiM'><ins id='8tuiM'></ins><ul id='8tuiM'></ul><sub id='8tuiM'></sub></form><legend id='8tuiM'></legend><bdo id='8tuiM'><pre id='8tuiM'><center id='8tuiM'></center></pre></bdo></b><th id='8tuiM'></th></span></q></dt></tr></i><div id='8tuiM'><tfoot id='8tuiM'></tfoot><dl id='8tuiM'><fieldset id='8tuiM'></fieldset></dl></div>