Split string in MYSQL via CRATE
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
|
show 1 more comment
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
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
|
show 1 more comment
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
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
mysql crate cratedb
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
|
show 1 more comment
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
|
show 1 more comment
3 Answers
3
active
oldest
votes
SUBSTRING_INDEX
comes in handy here:
SELECT
SUBSTRING_INDEX('1234-5656', '-', 1) AS first,
SUBSTRING_INDEX('1234-5656', '-', -1) AS second
FROM yourTable;
Unfortunately not working in CRATE
– anz
Nov 15 '18 at 6:01
add a comment |
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
add a comment |
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
add a comment |
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
);
);
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
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
SUBSTRING_INDEX
comes in handy here:
SELECT
SUBSTRING_INDEX('1234-5656', '-', 1) AS first,
SUBSTRING_INDEX('1234-5656', '-', -1) AS second
FROM yourTable;
Unfortunately not working in CRATE
– anz
Nov 15 '18 at 6:01
add a comment |
SUBSTRING_INDEX
comes in handy here:
SELECT
SUBSTRING_INDEX('1234-5656', '-', 1) AS first,
SUBSTRING_INDEX('1234-5656', '-', -1) AS second
FROM yourTable;
Unfortunately not working in CRATE
– anz
Nov 15 '18 at 6:01
add a comment |
SUBSTRING_INDEX
comes in handy here:
SELECT
SUBSTRING_INDEX('1234-5656', '-', 1) AS first,
SUBSTRING_INDEX('1234-5656', '-', -1) AS second
FROM yourTable;
SUBSTRING_INDEX
comes in handy here:
SELECT
SUBSTRING_INDEX('1234-5656', '-', 1) AS first,
SUBSTRING_INDEX('1234-5656', '-', -1) AS second
FROM yourTable;
answered Nov 15 '18 at 5:57
Tim BiegeleisenTim Biegeleisen
236k13100160
236k13100160
Unfortunately not working in CRATE
– anz
Nov 15 '18 at 6:01
add a comment |
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
add a comment |
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
add a comment |
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
add a comment |
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
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
edited Nov 15 '18 at 10:39
Madhur Sharma
1276
1276
answered Nov 15 '18 at 6:11
Atul AkabariAtul Akabari
954
954
add a comment |
add a comment |
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
add a comment |
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
add a comment |
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
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
answered Dec 29 '18 at 0:55
metasemetase
1731318
1731318
add a comment |
add a comment |
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.
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
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
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
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
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