Is it possible to create a mysql field which will only accept the characters a-zA-Z ?
Share
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
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.