This is a discussion on Obviously using the wrong command within the MySQL forums, part of the Database Server Software category; --> Based on some suggestions given in a previous thread for a different problem, I decided to try this. Purpose ...
| |||||||
| Register | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read |
| ||||
| Based on some suggestions given in a previous thread for a different problem, I decided to try this. Purpose is to find the "longest" value stored in a column in an existing table. SELECT COUNT(*),MIN(LENGTH(city)) FROM chemp SELECT COUNT(*),MAX(LENGTH(city)) FROM chemp SELECT COUNT(*),AVG(LENGTH(city)) FROM chemp Strange (to me) everyone of these queries comes back as "30" which is the column design width. In fact every record in this table has "null" as the value in "city". Column type is varchar - table type is InnoDB. Is there some other string function that would returned the desired information? TIA Lee |
| |||
| On 14 Feb, 19:17, Lee Peedin <lpeedinDONOTSP...@nc.rr.com> wrote: > Based on some suggestions given in a previous thread for a different > problem, I decided to try this. > > Purpose is to find the "longest" value stored in a column in an > existing table. > > SELECT COUNT(*),MIN(LENGTH(city)) FROM chemp > SELECT COUNT(*),MAX(LENGTH(city)) FROM chemp > SELECT COUNT(*),AVG(LENGTH(city)) FROM chemp > > Strange (to me) everyone of these queries comes back as "30" which is > the column design width. In fact every record in this table has > "null" as the value in "city". > > Column type is varchar - table type is InnoDB. Is there some other > string function that would returned the desired information? > > TIA > Lee What are you counting with the COUNT(*)? |
| |||
| On 15 Feb 2007 01:36:57 -0800, "Captain Paralytic" <paul_lautman@yahoo.com> wrote: >On 14 Feb, 19:17, Lee Peedin <lpeedinDONOTSP...@nc.rr.com> wrote: >> Based on some suggestions given in a previous thread for a different >> problem, I decided to try this. >> >> Purpose is to find the "longest" value stored in a column in an >> existing table. >> >> SELECT COUNT(*),MIN(LENGTH(city)) FROM chemp >> SELECT COUNT(*),MAX(LENGTH(city)) FROM chemp >> SELECT COUNT(*),AVG(LENGTH(city)) FROM chemp >> >> Strange (to me) everyone of these queries comes back as "30" which is >> the column design width. In fact every record in this table has >> "null" as the value in "city". >> >> Column type is varchar - table type is InnoDB. Is there some other >> string function that would returned the desired information? >> >> TIA >> Lee > >What are you counting with the COUNT(*)? The COUNT(*) was just to show the number of rows in the table (2602). I get the same result (30) if I remove the COUNT(*). Lee |
| ||||
| On Wed, 14 Feb 2007 19:17:54 GMT, Lee Peedin wrote: > Based on some suggestions given in a previous thread for a different > problem, I decided to try this. > > Purpose is to find the "longest" value stored in a column in an > existing table. > > SELECT COUNT(*),MIN(LENGTH(city)) FROM chemp > SELECT COUNT(*),MAX(LENGTH(city)) FROM chemp > SELECT COUNT(*),AVG(LENGTH(city)) FROM chemp > > Strange (to me) everyone of these queries comes back as "30" which is > the column design width. In fact every record in this table has > "null" as the value in "city". > > Column type is varchar - table type is InnoDB. Is there some other > string function that would returned the desired information? How long is a null? Try putting a value in column `city` in at least one row, and see what happens. -- 87. My vats of hazardous chemicals will be covered when not in use. Also, I will not construct walkways above them. --Peter Anspach's list of things to do as an Evil Overlord |