MySQL select rows according to field length

Hi guys,

I have some domain names stored in a database and I am trying to find domains which are only 3 characters in length.

I could use the MySQL function length(), but this would not return the required results as it would take into account the full length of the domain including extension (.com, etc…).

Is there a way I can get 3 character domains from the database like so: (would be returned) (would be returned) (would be returned) (would not be returned as it’s 4 characters in length)

Thanks in advance.

  LENGTH(SUBSTRING_INDEX(domain, '.', 1)) = 3

Thank you Dan, that worked great!