In my db data are stored like below:
Q_101_B1
Q_101_B2
Q_101_B17
Q_101_Bch1
Q_101_Ben1
Q_101_B238
Q_101_B
I have to pull only those data which has digits strictly after char 'B
', thus in this case it should pull all the data except these two Q_101_Bch1
, Q_101_Ben1
.
I have tried with this query:
select lang from test_table where lang REGEXP '^[Q_101_B]|[0-9]'
But unfortunately its pulling all of them.
What should be the exact regex for this query?
Note: Q_101_B
can be a different string which will come dynamically, and I will append this while building the query inside my PHP code.