PHPMyAdmin count characters in string

Hello,

I am using PHPMyAdmin and I need to count characters in a string. I am looking for any string with more than X characters.

I am thinking along the lines of

Select field1 from table where character count in field1 is greater than X

Even better would be if I could generate results where it selects field1 and gives me a count of the characters which I could then export to a .CSV file.

Thanks,

John
JohnAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

seanmccullyCommented:
SELECT CHAR_LENGTH(field1) as field1_len FROM table WHERE field1_len > X;

http://dev.mysql.com/doc/refman/5.0/en/string-functions.html#function_char-length
0
nemws1Database AdministratorCommented:
The SQL you're looking for is (replace 10 with whatever length you're looking for):
SELECT field1
FROM table
WHERE LENGTH(field1) > 10
;

Open in new window


PHPMyAdmin can easily export the results of this as CSV.  Select using ',' as a field delimited and enclose fields with a double quote " to make importing into Excel easier.
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
nemws1Database AdministratorCommented:
seanmccully, just an FYI, that's pretty much the way I would think it should work too, but you can't use field aliases in WHERE statements w/ MySQL.
0
JohnAuthor Commented:
Hello nenws1,

Thank you, that worked great!

John
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
MySQL Server

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.