Is it possible to create a mysql field which will only accept the characters a-zA-Z ?
Asked
Active
Viewed 204 times
1
-
sorry for not sketch correctly my idea. I rectified my question – user722756 Feb 22 '12 at 15:59
1 Answers
2
You will need to look at the REGEX replace function detailed here How to count words in MySQL / regular expression replacer? (involves a UDF though) which you would need to use on a BEFORE INSERT trigger.
Alternatively you can look at sanitising the input in your code prior to insertion. This would be a more efficient method as most languages i.e. PHP support Regex, so a simple regex replace before insertion would be trivial.
MySQL unfortunately has no way to specify constraints such as this on columns.

Community
- 1
- 1

Simon at The Access Group
- 6,932
- 22
- 45