Jump to content

[SOLVED] selecting values of a certain length


tommo74

Recommended Posts

If I've got a table with a column of Surnames, is there any way to select all the surnames that are shorter than 5 letters long.

I know I could return ALL the surnames in a result set and go through the result set to check the length of each one individually, but is there a query where I could return just the Surnames shorter than 5 letters ?

Link to comment
Share on other sites

length() may not be accurate, i think you might mean char_length() ?

 

as mysql points out:

 

A multi-byte character counts as a single character. This means that for a string containing five two-byte characters, LENGTH() returns 10, whereas CHAR_LENGTH() returns 5.

 

although length would still work in most cases (as far as i understand it)

 

;D

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.