Unix Technical Forum

Obviously using the wrong command

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 ...


Go Back   Unix Technical Forum > Database Server Software > MySQL

Register FAQ Members List Calendar Search Today's Posts Mark Forums Read
  #1 (permalink)  
Old 02-28-2008, 09:10 AM
Lee Peedin
 
Posts: n/a
Default Obviously using the wrong command

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



Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #2 (permalink)  
Old 02-28-2008, 09:10 AM
Captain Paralytic
 
Posts: n/a
Default Re: Obviously using the wrong command

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(*)?

Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #3 (permalink)  
Old 02-28-2008, 09:10 AM
Lee Peedin
 
Posts: n/a
Default Re: Obviously using the wrong command

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
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #4 (permalink)  
Old 02-28-2008, 09:10 AM
Peter H. Coffin
 
Posts: n/a
Default Re: Obviously using the wrong command

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
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On
Forum Jump


All times are GMT. The time now is 12:18 AM.


Powered by vBulletin® Version 3.6.5
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
SEO by vBSEO 3.2.0
www.UnixAdminTalk.com