Split string in MYSQL via CRATE










-2















I want to split a string in CRATE. I tried with substr, but it takes only substr(string,long,long). I want something like a function which can take delimiter string.



Example :



value=1234-5656



select SUBSTR(value, '-',1) as first from XYZ;



I want to split the value into 1234 and 5656 in a SQL query. But CRATE does not support SUBSTR(value, '-',1). So I am looking for an option to split the value in the CRATE query.



Any help?










share|improve this question
























  • It is entirely unclear what you are asking here. Please edit your question, and show some sample data, along with whatever SQL you have already tried.

    – Tim Biegeleisen
    Nov 15 '18 at 5:45











  • Hope its clear now.

    – anz
    Nov 15 '18 at 5:51











  • Duplicate of stackoverflow.com/questions/34992575/… (which is again a duplicate)?

    – Caesar
    Nov 15 '18 at 5:55











  • Are you using MySQL or something else?

    – Tim Biegeleisen
    Nov 15 '18 at 6:01











  • Why don't you use procedure for this issue. I dont think with simple create query you can able to do it.

    – Kandy
    Nov 15 '18 at 6:03















-2















I want to split a string in CRATE. I tried with substr, but it takes only substr(string,long,long). I want something like a function which can take delimiter string.



Example :



value=1234-5656



select SUBSTR(value, '-',1) as first from XYZ;



I want to split the value into 1234 and 5656 in a SQL query. But CRATE does not support SUBSTR(value, '-',1). So I am looking for an option to split the value in the CRATE query.



Any help?










share|improve this question
























  • It is entirely unclear what you are asking here. Please edit your question, and show some sample data, along with whatever SQL you have already tried.

    – Tim Biegeleisen
    Nov 15 '18 at 5:45











  • Hope its clear now.

    – anz
    Nov 15 '18 at 5:51











  • Duplicate of stackoverflow.com/questions/34992575/… (which is again a duplicate)?

    – Caesar
    Nov 15 '18 at 5:55











  • Are you using MySQL or something else?

    – Tim Biegeleisen
    Nov 15 '18 at 6:01











  • Why don't you use procedure for this issue. I dont think with simple create query you can able to do it.

    – Kandy
    Nov 15 '18 at 6:03













-2












-2








-2








I want to split a string in CRATE. I tried with substr, but it takes only substr(string,long,long). I want something like a function which can take delimiter string.



Example :



value=1234-5656



select SUBSTR(value, '-',1) as first from XYZ;



I want to split the value into 1234 and 5656 in a SQL query. But CRATE does not support SUBSTR(value, '-',1). So I am looking for an option to split the value in the CRATE query.



Any help?










share|improve this question
















I want to split a string in CRATE. I tried with substr, but it takes only substr(string,long,long). I want something like a function which can take delimiter string.



Example :



value=1234-5656



select SUBSTR(value, '-',1) as first from XYZ;



I want to split the value into 1234 and 5656 in a SQL query. But CRATE does not support SUBSTR(value, '-',1). So I am looking for an option to split the value in the CRATE query.



Any help?







mysql crate cratedb






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Nov 15 '18 at 5:50







anz

















asked Nov 15 '18 at 5:42









anzanz

7319




7319












  • It is entirely unclear what you are asking here. Please edit your question, and show some sample data, along with whatever SQL you have already tried.

    – Tim Biegeleisen
    Nov 15 '18 at 5:45











  • Hope its clear now.

    – anz
    Nov 15 '18 at 5:51











  • Duplicate of stackoverflow.com/questions/34992575/… (which is again a duplicate)?

    – Caesar
    Nov 15 '18 at 5:55











  • Are you using MySQL or something else?

    – Tim Biegeleisen
    Nov 15 '18 at 6:01











  • Why don't you use procedure for this issue. I dont think with simple create query you can able to do it.

    – Kandy
    Nov 15 '18 at 6:03

















  • It is entirely unclear what you are asking here. Please edit your question, and show some sample data, along with whatever SQL you have already tried.

    – Tim Biegeleisen
    Nov 15 '18 at 5:45











  • Hope its clear now.

    – anz
    Nov 15 '18 at 5:51











  • Duplicate of stackoverflow.com/questions/34992575/… (which is again a duplicate)?

    – Caesar
    Nov 15 '18 at 5:55











  • Are you using MySQL or something else?

    – Tim Biegeleisen
    Nov 15 '18 at 6:01











  • Why don't you use procedure for this issue. I dont think with simple create query you can able to do it.

    – Kandy
    Nov 15 '18 at 6:03
















It is entirely unclear what you are asking here. Please edit your question, and show some sample data, along with whatever SQL you have already tried.

– Tim Biegeleisen
Nov 15 '18 at 5:45





It is entirely unclear what you are asking here. Please edit your question, and show some sample data, along with whatever SQL you have already tried.

– Tim Biegeleisen
Nov 15 '18 at 5:45













Hope its clear now.

– anz
Nov 15 '18 at 5:51





Hope its clear now.

– anz
Nov 15 '18 at 5:51













Duplicate of stackoverflow.com/questions/34992575/… (which is again a duplicate)?

– Caesar
Nov 15 '18 at 5:55





Duplicate of stackoverflow.com/questions/34992575/… (which is again a duplicate)?

– Caesar
Nov 15 '18 at 5:55













Are you using MySQL or something else?

– Tim Biegeleisen
Nov 15 '18 at 6:01





Are you using MySQL or something else?

– Tim Biegeleisen
Nov 15 '18 at 6:01













Why don't you use procedure for this issue. I dont think with simple create query you can able to do it.

– Kandy
Nov 15 '18 at 6:03





Why don't you use procedure for this issue. I dont think with simple create query you can able to do it.

– Kandy
Nov 15 '18 at 6:03












3 Answers
3






active

oldest

votes


















0














SUBSTRING_INDEX comes in handy here:



SELECT
SUBSTRING_INDEX('1234-5656', '-', 1) AS first,
SUBSTRING_INDEX('1234-5656', '-', -1) AS second
FROM yourTable;


enter image description here






share|improve this answer























  • Unfortunately not working in CRATE

    – anz
    Nov 15 '18 at 6:01


















0














please try using this query:



SELECT SUBSTRING_INDEX(SUBSTRING_INDEX(name, '_', 1), '_', -1) as beforesplit, SUBSTRING_INDEX(SUBSTRING_INDEX(name, '_', 2), '_', -1) as aftersplit FROM testenter





share|improve this answer
































    0














    For CrateDB you probably want to use regex_matches function more info on Create's documentation site



    However the following should give you what you're looking for



    select regexp_matches(yourColumnName, '([0-9])w+')[1] from yourTable 





    share|improve this answer























      Your Answer






      StackExchange.ifUsing("editor", function ()
      StackExchange.using("externalEditor", function ()
      StackExchange.using("snippets", function ()
      StackExchange.snippets.init();
      );
      );
      , "code-snippets");

      StackExchange.ready(function()
      var channelOptions =
      tags: "".split(" "),
      id: "1"
      ;
      initTagRenderer("".split(" "), "".split(" "), channelOptions);

      StackExchange.using("externalEditor", function()
      // Have to fire editor after snippets, if snippets enabled
      if (StackExchange.settings.snippets.snippetsEnabled)
      StackExchange.using("snippets", function()
      createEditor();
      );

      else
      createEditor();

      );

      function createEditor()
      StackExchange.prepareEditor(
      heartbeatType: 'answer',
      autoActivateHeartbeat: false,
      convertImagesToLinks: true,
      noModals: true,
      showLowRepImageUploadWarning: true,
      reputationToPostImages: 10,
      bindNavPrevention: true,
      postfix: "",
      imageUploader:
      brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
      contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
      allowUrls: true
      ,
      onDemand: true,
      discardSelector: ".discard-answer"
      ,immediatelyShowMarkdownHelp:true
      );



      );













      draft saved

      draft discarded


















      StackExchange.ready(
      function ()
      StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53313120%2fsplit-string-in-mysql-via-crate%23new-answer', 'question_page');

      );

      Post as a guest















      Required, but never shown

























      3 Answers
      3






      active

      oldest

      votes








      3 Answers
      3






      active

      oldest

      votes









      active

      oldest

      votes






      active

      oldest

      votes









      0














      SUBSTRING_INDEX comes in handy here:



      SELECT
      SUBSTRING_INDEX('1234-5656', '-', 1) AS first,
      SUBSTRING_INDEX('1234-5656', '-', -1) AS second
      FROM yourTable;


      enter image description here






      share|improve this answer























      • Unfortunately not working in CRATE

        – anz
        Nov 15 '18 at 6:01















      0














      SUBSTRING_INDEX comes in handy here:



      SELECT
      SUBSTRING_INDEX('1234-5656', '-', 1) AS first,
      SUBSTRING_INDEX('1234-5656', '-', -1) AS second
      FROM yourTable;


      enter image description here






      share|improve this answer























      • Unfortunately not working in CRATE

        – anz
        Nov 15 '18 at 6:01













      0












      0








      0







      SUBSTRING_INDEX comes in handy here:



      SELECT
      SUBSTRING_INDEX('1234-5656', '-', 1) AS first,
      SUBSTRING_INDEX('1234-5656', '-', -1) AS second
      FROM yourTable;


      enter image description here






      share|improve this answer













      SUBSTRING_INDEX comes in handy here:



      SELECT
      SUBSTRING_INDEX('1234-5656', '-', 1) AS first,
      SUBSTRING_INDEX('1234-5656', '-', -1) AS second
      FROM yourTable;


      enter image description here







      share|improve this answer












      share|improve this answer



      share|improve this answer










      answered Nov 15 '18 at 5:57









      Tim BiegeleisenTim Biegeleisen

      236k13100160




      236k13100160












      • Unfortunately not working in CRATE

        – anz
        Nov 15 '18 at 6:01

















      • Unfortunately not working in CRATE

        – anz
        Nov 15 '18 at 6:01
















      Unfortunately not working in CRATE

      – anz
      Nov 15 '18 at 6:01





      Unfortunately not working in CRATE

      – anz
      Nov 15 '18 at 6:01













      0














      please try using this query:



      SELECT SUBSTRING_INDEX(SUBSTRING_INDEX(name, '_', 1), '_', -1) as beforesplit, SUBSTRING_INDEX(SUBSTRING_INDEX(name, '_', 2), '_', -1) as aftersplit FROM testenter





      share|improve this answer





























        0














        please try using this query:



        SELECT SUBSTRING_INDEX(SUBSTRING_INDEX(name, '_', 1), '_', -1) as beforesplit, SUBSTRING_INDEX(SUBSTRING_INDEX(name, '_', 2), '_', -1) as aftersplit FROM testenter





        share|improve this answer



























          0












          0








          0







          please try using this query:



          SELECT SUBSTRING_INDEX(SUBSTRING_INDEX(name, '_', 1), '_', -1) as beforesplit, SUBSTRING_INDEX(SUBSTRING_INDEX(name, '_', 2), '_', -1) as aftersplit FROM testenter





          share|improve this answer















          please try using this query:



          SELECT SUBSTRING_INDEX(SUBSTRING_INDEX(name, '_', 1), '_', -1) as beforesplit, SUBSTRING_INDEX(SUBSTRING_INDEX(name, '_', 2), '_', -1) as aftersplit FROM testenter






          share|improve this answer














          share|improve this answer



          share|improve this answer








          edited Nov 15 '18 at 10:39









          Madhur Sharma

          1276




          1276










          answered Nov 15 '18 at 6:11









          Atul AkabariAtul Akabari

          954




          954





















              0














              For CrateDB you probably want to use regex_matches function more info on Create's documentation site



              However the following should give you what you're looking for



              select regexp_matches(yourColumnName, '([0-9])w+')[1] from yourTable 





              share|improve this answer



























                0














                For CrateDB you probably want to use regex_matches function more info on Create's documentation site



                However the following should give you what you're looking for



                select regexp_matches(yourColumnName, '([0-9])w+')[1] from yourTable 





                share|improve this answer

























                  0












                  0








                  0







                  For CrateDB you probably want to use regex_matches function more info on Create's documentation site



                  However the following should give you what you're looking for



                  select regexp_matches(yourColumnName, '([0-9])w+')[1] from yourTable 





                  share|improve this answer













                  For CrateDB you probably want to use regex_matches function more info on Create's documentation site



                  However the following should give you what you're looking for



                  select regexp_matches(yourColumnName, '([0-9])w+')[1] from yourTable 






                  share|improve this answer












                  share|improve this answer



                  share|improve this answer










                  answered Dec 29 '18 at 0:55









                  metasemetase

                  1731318




                  1731318



























                      draft saved

                      draft discarded
















































                      Thanks for contributing an answer to Stack Overflow!


                      • Please be sure to answer the question. Provide details and share your research!

                      But avoid


                      • Asking for help, clarification, or responding to other answers.

                      • Making statements based on opinion; back them up with references or personal experience.

                      To learn more, see our tips on writing great answers.




                      draft saved


                      draft discarded














                      StackExchange.ready(
                      function ()
                      StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53313120%2fsplit-string-in-mysql-via-crate%23new-answer', 'question_page');

                      );

                      Post as a guest















                      Required, but never shown





















































                      Required, but never shown














                      Required, but never shown












                      Required, but never shown







                      Required, but never shown

































                      Required, but never shown














                      Required, but never shown












                      Required, but never shown







                      Required, but never shown







                      Popular posts from this blog

                      Use pre created SQLite database for Android project in kotlin

                      Darth Vader #20

                      Ondo