PHPMyAdmin count characters in string

Posted on 2011-10-04
Last Modified: 2012-05-12

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.


Question by:jpldpd
    LVL 3

    Expert Comment

    SELECT CHAR_LENGTH(field1) as field1_len FROM table WHERE field1_len > X;
    LVL 23

    Accepted Solution

    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.
    LVL 23

    Expert Comment

    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.

    Author Comment

    Hello nenws1,

    Thank you, that worked great!


    Featured Post

    Free Trending Threat Insights Every Day

    Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

    Join & Write a Comment

    If you find yourself in this situation “I have used SELECT DISTINCT but I’m getting duplicates” then I'm sorry to say you are using the wrong SQL technique as it only does one thing which is: produces whole rows that are unique. If the results you a…
    PL/SQL can be a very powerful tool for working directly with database tables. Being able to loop will allow you to perform more complex operations, but can be a little tricky to write correctly. This article will provide examples of basic loops alon…
    In this sixth video of the Xpdf series, we discuss and demonstrate the PDFtoPNG utility, which converts a multi-page PDF file to separate color, grayscale, or monochrome PNG files, creating one PNG file for each page in the PDF. It does this via a c…
    This video gives you a great overview about bandwidth monitoring with SNMP and WMI with our network monitoring solution PRTG Network Monitor ( If you're looking for how to monitor bandwidth using netflow or packet s…

    734 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    25 Experts available now in Live!

    Get 1:1 Help Now