0

My sql script is like this :

SELECT hotel_code, star FROM hotel WHERE star REGEXP '^[A-Za-z0-9]+$'

The result is like this :

http://snag.gy/kQ7t6.jpg

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

vascowhite
  • 18,120
  • 9
  • 61
  • 77
moses toh
  • 12,344
  • 71
  • 243
  • 443

3 Answers3

2

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]*)$
Alok Patel
  • 7,842
  • 5
  • 31
  • 47
0

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.

Andrewus
  • 248
  • 1
  • 9
0

you can try with this..

SELECT hotel_code, star FROM hotel WHERE star REGEXP '^(?=.*[a-zA-Z])(?=.*[0-9])'