Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to filter rows based on the character length of a field

Tags:

text

mysql

I have a table with column "id" and "description". Need to find those rows where description has more than 100 characters in it?

EDIT: now got the Above question.. But is there any way to get the count of number of characters ?

like image 809
Parth mehta Avatar asked Feb 10 '12 05:02

Parth mehta


People also ask

Can you filter by character length in Excel?

2.1) In the Range box, select the column you will filter the data by length; 2.2) In the Filter rules section, keep the Text option selected, choose Text length equal to option from the drop-down, and then enter the length of characters into the textbox; 2.3) Click the OK button.

How do I filter multiple rows in Excel based on cell value?

(1.) Select Filter the list, in-place option from the Action section; (2.) Then, select the data range that you want to filter in the List range, and specify the list of multiple values you want to filter based on in the Criteria range; (Note: The header name of the filter column and criteria list must be the same.)

How do I filter a row based on a list?

You can use the FILTER and COUNTIF functions to filter based on a list in Excel. To filter by a list in Excel, use the COUNTIF function to give an indication of whether or not each row meets your criteria, and then use the FILTER function to filter out the rows that do not meet your criteria.


1 Answers

Use the char_length() string function.

SELECT * FROM table WHERE char_length(description) > 100

Check out more information here http://dev.mysql.com/doc/refman/5.0/en/string-functions.html#function_char-length

like image 157
chadmaughan Avatar answered Nov 14 '22 22:11

chadmaughan