0

I want to get the data numbers from the string in this format using Mysql:

A-10001(b)

Which means the output should be something like:

10001

I would like to know whether there is a way which is better than using SUBSTRING. Thanks.

7
  • Can you share your current query with us? Commented Feb 12, 2018 at 12:02
  • Maybe this link can help you... you should add a MySQL function for that. Let me know if it helps you!!! Commented Feb 12, 2018 at 12:13
  • This probably won't help with your current problem but with mysql version 8.0 you'll be able to use REGEXP_SUBSTR dev.mysql.com/doc/refman/8.0/en/… Commented Feb 12, 2018 at 12:43
  • @Alvaro Niño: It helps!!! Thank you so much. Commented Feb 13, 2018 at 10:41
  • You are welcome, remember to vote up if it helps you @AlvinLau Commented Feb 13, 2018 at 11:07

1 Answer 1

1

Is there a way which is better than using SUBSTRING [to pull 10001 from A-10001(b) ?

No. Not in a MySQL query. Whatever you do will almost certainly end up involving SUBSTRING().

A wise programmer might choose to do this in a host language, like php or Java.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.