Mertens Bram wrote: > Hi, > > How can I find the longest string in a column? > > I can probably write a PHP-script that checks the str_length > recursively, but I would like to be able to do this within MySQL... > > I would like to have the value and the length of the string if this is > possible. Is this possible or should I try to write the PHP-script? > > I couldn't find anything relevant in the documentation or the archives, > but I hope I just missed it... > > TIA, > > Bram > [sql, query]
Hi, You could try: SELECT string,length(string) as len FROM mytable ORDER BY len DESC LIMIT 1 regards, Joseph Bueno --------------------------------------------------------------------- Before posting, please check: http://www.mysql.com/manual.php (the manual) http://lists.mysql.com/ (the list archive) To request this thread, e-mail <[EMAIL PROTECTED]> To unsubscribe, e-mail <[EMAIL PROTECTED]> Trouble unsubscribing? Try: http://lists.mysql.com/php/unsubscribe.php