0

In MySQL if a string in a column is 5 or less characters long or then select them else discard them. I may be not good in explaining them but the following scenario will explain it. I have data in column

Ram.
RamS.
Ram-S
Ram..
RAm.
RAmS.
Ramazan..
9R1..
9R11.
9R12.
9R13.
9R14.
9R15.
9R1Z.
9R1rA
9R1-S
9R1rAMS
9R1rR
9R1S-
9R1aA
9R1rAMS123

If it is 5 character long and if there is a dot then select all the corresponding values like this for value 9R1

9R1..
9R11.
9R12.
9R13.
9R14.
9R15.
9R1Z.
9R1rA
9R1-S
9R1rR
9R1S-
9R1aA

I tried this

SELECT * FROM `ramstest`
WHERE  `Test1`
REGEXP BINARY "^9R1[A-Za-z\\.\\-]{1,2}"

but did not work. I will appreciate some help

Jens
  • 67,715
  • 15
  • 98
  • 113

0 Answers0