Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium


PHPMyAdmin count characters in string

Posted on 2011-10-04
Medium Priority
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
  • 2

Expert Comment

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

LVL 23

Accepted Solution

nemws1 earned 2000 total points
ID: 36910849
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

ID: 36910864
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

ID: 36910980
Hello nenws1,

Thank you, that worked great!


Featured Post

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

In this series, we will discuss common questions received as a database Solutions Engineer at Percona. In this role, we speak with a wide array of MySQL and MongoDB users responsible for both extremely large and complex environments to smaller singl…
MSSQL DB-maintenance also needs implementation of multiple activities. However, unprecedented errors can hamper the database management. In that case, deploying Stellar SQL Database Toolkit ensures fast and accurate database and backup repair as wel…
In this video, Percona Solutions Engineer Barrett Chambers discusses some of the basic syntax differences between MySQL and MongoDB. To learn more check out our webinar on MongoDB administration for MySQL DBA: https://www.percona.com/resources/we…
With just a little bit of  SQL and VBA, many doors open to cool things like synchronize a list box to display data relevant to other information on a form.  If you have never written code or looked at an SQL statement before, no problem! ...  give i…

580 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