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 ?

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

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.