0

I would like to create a mysql query that would exclude rows starting by digits using regexp. For instance here I have 1 column "indicators" with the following values:

5-Year Treasury Gilt Auction
52-Week Bill Auction
6-Month Bill Auction
ADP Nonfarm Employment Change
All Car Sales

I would like to create a query such as :

SELECT * FROM table WHERE indicators = [does not start with a digit...];

What is the right way to express such query in mysql?

1 Answer 1

3

You can just do:

select t.*
from t
where t.indicators regexp '^[^0-9].*$'

Or, you don't need regular expressions at all:

where left(t.indicators, 1) not between '0' and '9'
Sign up to request clarification or add additional context in comments.

4 Comments

sorry i am quite noob: why t.* ? why not just *
@GordonLinoff nice one +1 from me
@jimbasquiat both are same you can use * to select all columns. but if you join multiple tables then better to use tableName.tablecolumnName to avoid ambiguous column error.

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.