Reputation: 363
For example:
CE-0392(Ne)
CEU-29221(PR)
Expected result:
0392
29221
How can this be done?
Upvotes: 0
Views: 38
Reputation: 159
I'm not sure to have the correct answer 'cause your question is not clear, please add more details (are CE-0392(Ne)
and CEU-29221(PR)
extracted from a query ? If yes which one ? )
You can use MySQL String function like, like:
SELECT SUBSTRING_INDEX('CE-0392(Ne)','(',1);
Please visit http://www.w3resource.com/mysql/string-functions/mysql-substring_index-function.php for further reference.
Upvotes: 0
Reputation: 140
One way would be:
SELECT SUBSTRING("CE-0392(Ne)", 4,4) AS ExtractString;
SELECT SUBSTRING("CEU-29221(PR)", 5,5) AS ExtractString;
But you could use a mix of LEFT and LOCATE or even SUBSTRING_INDEX if you characters are fixed, for instance, always between -
and (
.
SELECT SUBSTRING_INDEX(SUBSTRING_INDEX("CE-0392(Ne)", '-', -1),'(', 1) AS ExtractString;
Upvotes: 1