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 子串的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

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

                相关文档推荐

                Can#39;t Create Entity Data Model - using MySql and EF6(无法创建实体数据模型 - 使用 MySql 和 EF6)
                MySQL select with CONCAT condition(MySQL选择与CONCAT条件)
                Capitalize first letter of each word, in existing table(将现有表格中每个单词的首字母大写)
                How to retrieve SQL result column value using column name in Python?(如何在 Python 中使用列名检索 SQL 结果列值?)
                Update row with data from another row in the same table(使用同一表中另一行的数据更新行)
                Exporting results of a Mysql query to excel?(将 Mysql 查询的结果导出到 excel?)

                <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>