Re: most occured word - but without search

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



That will only count the rows containing the keyword, not the occurances 
of the keyword. If a row contains the keyword twice it will only be seen 
as one occurance.

Krishna Srikanth wrote:
> 
> 
> Hi,
> 
> There is no need to getback the huge dataset to php just for counting. You
> can do it at database itself level itself, using wild cards and count
> function.
> 
> select count(*) from table_name where person_name like 'John%' -- you can
> use %John% too
> 
> so your php script will be
> 
> $sql="select count(*) as Count from table_name where person_name like
> '{$_POST['search_field']}%'";
> $db->query($sql);
> $count=$db->rows[0]['Count'];
> 
> Bye,
> Manda Krishna Srikanth
> http://www.krishnasrikanth.com <http://www.krishnasrikanth.com>
> 
> php-objects@xxxxxxxxxxxxxxx <mailto:php-objects%40yahoogroups.com> wrote 
> on 09/18/2007 03:10:25 PM:
> 
>  > Sorry I just read your question a bit closer, I am not sure if you can
>  > count the number of occurences using mysql, but you can certainly find
>  > out where they are.
>  >
>  > I guess you could try reading each word and creating a count manually
>  > with php, but that could get slow for a massive number of rows.
>  >
>  > Imran wrote:
>  > >
>  > >
>  > > Dear Friends,
>  > >
>  > > Is there any MySQL query that could find the most occured word in a
> column
>  > > of a table, without searching it?
>  > >
>  > > e.g.,
>  > >
>  > > *Column Name*
>  > > - - - - - - - - - - -
>  > > John
>  > > James Bond
>  > > John
>  > > Alix
>  > > Philips
>  > > John
>  > > - - - - - - - - - -
>  > >
>  > > So, without search, we want to see that John has occured 3 times.
>  > >
>  > > Sql Query is appreciated.... if possible?
>  > >
>  > > Thanks v.much,
>  > > Imran
>  > >
> =====-----=====-----=====
> Notice: The information contained in this e-mail
> message and/or attachments to it may contain
> confidential or privileged information. If you are
> not the intended recipient, any dissemination, use,
> review, distribution, printing or copying of the
> information contained in this e-mail message
> and/or attachments to it are strictly prohibited. If
> you have received this communication in error,
> please notify us by reply e-mail or telephone and
> immediately and permanently delete the message
> and any attachments. Thank you
> 
> [Non-text portions of this message have been removed]
> 
> 

[Index of Archives]     [PHP Home]     [PHP Users]     [PHP Soap]     [Kernel Newbies]     [Yosemite]     [Yosemite Campsites]

  Powered by Linux