I need to fetch all the rows where the ‘zip’ field is less than 5 characters. How can I achieve this using only SQL? I google’d first, but only found info on CHAR_LENGTH().
ie, psudeo code: SELECT * FROM users WHERE STRLEN(zip_code) < 5
Thanks!
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.
For MySQL you would use the LENGTH() function ie.
Refer to the docs at http://dev.mysql.com/doc/refman/5.1/en/string-functions.html#function_length for more information.