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

        <legend id='wuJVI'><style id='wuJVI'><dir id='wuJVI'><q id='wuJVI'></q></dir></style></legend>
      1. <small id='wuJVI'></small><noframes id='wuJVI'>

        拆分逗号分隔的字符串 -->FUNCTION db.CHARINDEX 不存在

        时间:2024-04-16

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

          <legend id='N6lp7'><style id='N6lp7'><dir id='N6lp7'><q id='N6lp7'></q></dir></style></legend>
        1. <tfoot id='N6lp7'></tfoot>

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

              • <bdo id='N6lp7'></bdo><ul id='N6lp7'></ul>
                1. 本文介绍了拆分逗号分隔的字符串 -->FUNCTION db.CHARINDEX 不存在的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                  问题描述

                  我需要将逗号分隔的字符串拆分为第二列我有下表:

                  I need to split comma delimited string into a second columns I have the following table :

                  CL1     POS                 POS2     LENGHT     ALLELE
                  1       3015108,3015109              5          A
                  2       3015110,3015200              10         B
                  3       3015200,3015300              15         C
                  4       3015450,3015500              20         D
                  5       3015600,3015700              15         E
                  

                  我想将逗号后的数字拆分为第二列 POS2所以它应该喜欢

                  I want to split the numbers after the comma into a second column POS2 So it should like that

                  CL1     POS                 POS2     LENGHT     ALLELE
                  1       3015108             3015109  5          A
                  2       3015110             3015200  10         B
                  3       3015200             3015300  15         C
                  4       3015450             3015500  20         D
                  5       3015600             3015700  15         E
                  

                  所以我查询了以下内容:

                  So I've queried the following :

                  INSERT INTO MyTable (POS2)
                  SELECT RIGHT(POS, CHARINDEX(',', POS) + 1 ) FROM MyTable ;
                  
                  
                   It returns an error : 
                   ERROR 1305 (42000): FUNCTION test.CHARINDEX does not exist
                  

                  推荐答案

                  MySQL 没有内置的 CHARINDEX() 函数.LOCATE() 将是 MySQL等价.

                  MySQL doesn't have a built-in CHARINDEX() function. LOCATE() would be the MySQL equivalent.

                  使用SUBSTRING_INDEX() 可能是一种更简洁的方法.像这样的东西(免责声明:未经测试):

                  Using SUBSTRING_INDEX() might be a more succinct way of doing this. Something like this (disclaimer: untested):

                  SUBSTRING_INDEX(POS, ',', 1) 用于 POS

                  SUBSTRING_INDEX(POS, ',', -1) 用于 POS2

                  顺便说一句,我可能误解了您要完成的任务,但您似乎想要UPDATE 现有行,而不是 INSERT 新行?类似的东西:

                  As an aside, I may be misunderstanding what you're trying to accomplish, but it looks like you might want to UPDATE existing rows, not INSERT new ones? Something like:

                  UPDATE MyTable SET POS2 = SUBSTRING_INDEX(POS, ',', -1);
                  UPDATE MyTable SET POS = SUBSTRING_INDEX(POS, ',', 1);
                  

                  这篇关于拆分逗号分隔的字符串 -->FUNCTION db.CHARINDEX 不存在的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                  上一篇:MYSQL - 将数据拆分为多行 下一篇:使用 regexp_substr 在 Oracle 中按空格和字符作为分隔符拆分字符串

                  相关文章

                  1. <small id='JlXAh'></small><noframes id='JlXAh'>

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