Reputation: 13172
My sql script is like this :
SELECT hotel_code, star FROM hotel WHERE star REGEXP '^[A-Za-z0-9]+$'
The result is like this :
I want the result of select the field that contains numbers and letters.
So, the result is like this :
3EST
2EST
Any solution to solve my problem
Thank you
Upvotes: 0
Views: 1483
Reputation: 743
you can try with this..
SELECT hotel_code, star FROM hotel WHERE star REGEXP '^(?=.*[a-zA-Z])(?=.*[0-9])'
Upvotes: 0
Reputation: 8022
I guess you're trying to get Must alphanumeric values. It can be achieved by following.
^([0-9]+[A-Za-z]+[0-9]*)|([A-Za-z]+[0-9]+[A-Za-z]*)$
Upvotes: 2
Reputation: 248
The solution seems be like that:
'^[A-Za-z]+[0-9]+[A-Za-z0-9]+$|^[0-9]+[A-Za-z]+[A-Za-z0-9]+$'
You'll find elements beginning with letters and numbers OR numbers and letters and then containing both ones.
Upvotes: 0