I need to character count the sum of all the characters in a text based field in MySQL. I need to know the total number of characters of all the posts in that field combined, and can't think how I'd do this...
Any help would be great.
Thanks.
MySQL CHAR_LENGTH() function MySQL CHAR_LENGTH() returns the length (how many characters are there) of a given string. The function simply counts the number characters and ignore whether the character(s) are single-byte or multi-byte.
To counts all of the rows in a table, whether they contain NULL values or not, use COUNT(*). That form of the COUNT() function basically returns the number of rows in a result set returned by a SELECT statement.
The FROM clause in SQL specifies which table we want to list. You can also use the ALL keyword in the COUNT function. SELECT COUNT(ALL column_name) FROM table_name; The ALL keyword will count all values in the table including duplicates.
If you need a quick way to count rows that contain data, select all the cells in the first column of that data (it may not be column A). Just click the column header. The status bar, in the lower-right corner of your Excel window, will tell you the row count.
For the number of bytes . . .
select sum(length(your_column_name))
from your_table_name;
For the number of characters . . .
select sum(char_length(your_column_name))
from your_table_name;
The char_length() function accommodates multi-byte characters; five two-byte characters will return as 5.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With