Computing.Net > Forums > Programming > [mysql] select longest string

Computer Problems? Computing.Net has over 1,000,000 posts about all things technology related! Over 90% answered within 24 hours! Click here to start participating now! Also, be sure to check out the New User Guide.

[mysql] select longest string

Reply to Message Icon

Name: Laler
Date: May 3, 2004 at 19:54:36 Pacific
OS: p3 866
CPU/Ram: XP pro
Comment:

hello,

in mysql, let's say I have a column of country names...

how can I get the "longest country name" then ?

thanks



Sponsored Link
Ads by Google

Response Number 1
Name: wharfie
Date: May 4, 2004 at 17:58:04 Pacific
Reply:

Assuming COUNTRY_NAME is of type CHAR;

select COUNTRY_NAME from COUNTRIES where length(trim(COUNTRY_NAME)) =
(select max(length(trim(COUNTRY_NAME))) from COUNTRIES)

If COUNTRY_NAME is VARCHAR you can leave out the trim()


0

Response Number 2
Name: Laler
Date: May 8, 2004 at 10:27:45 Pacific
Reply:

thanks :D


0

Sponsored Link
Ads by Google
Reply to Message Icon

Related Posts

See More







Post Locked

This post is quite old and has been locked from receiving new replies. Please create a new posting instead.


Go to Programming Forum Home


Sponsored links

Ads by Google


Results for: [mysql] select longest string

VB6 Mysql remote connection string www.computing.net/answers/programming/vb6-mysql-remote-connection-string/13709.html

mysql vb6 Connection String www.computing.net/answers/programming/mysql-vb6-connection-string/13719.html

Coding selection.areas in VBA www.computing.net/answers/programming/coding-selectionareas-in-vba-/7893.html