Finding the longest string with Mysql

I recently wanted to find the length of the longest string from a column in a mysql table.

SELECT MAX(LENGTH(c1)) FROM t1 will give a different result to SELECT LENGTH(MAX(c1)) FROM t1 The first one gives the correct result!

Just wanted to save you some hours!

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.