Re: [PHP] Insert group by

2012-04-27 Thread Lester Caine

Rick Dwyer wrote:

This is more of a MySQL question, but I'm hoping it can be answered here.
On one of my pages, I issue a SQL command to group data as such:

$sql='select count(*) as count, searchkeywords from searchkeywords group by 
searchkeywords order by count desc'

Works well... but I would like it to groups plurals with singular words as well.  So 
hats are grouped with hat.

Since I'm doing a group by column name, I don't know that this can be done.

Any help is appreciated.


This IS a more appropriate question for ANY of the other database lists ;)

Normal practice is to create a search field that has your preferred search 
style, so add 'filtered_searchwords' and populate it with say a lower case copy 
of searchkeywords with any s or 's text removed. That is unless you want 
Hat's counted separately?


Expecting the database to process this type of filtering with any speed is being 
a bit hopeful. What any database does is processes raw fields fast, so providing 
extra data at insert or edit time is much more efficient than trying to do that 
process on every row of data later.


--
Lester Caine - G8HFL
-
Contact - http://lsces.co.uk/wiki/?page=contact
L.S.Caine Electronic Services - http://lsces.co.uk
EnquirySolve - http://enquirysolve.com/
Model Engineers Digital Workshop - http://medw.co.uk//
Firebird - http://www.firebirdsql.org/index.php

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



RE: [PHP] Insert group by

2012-04-27 Thread admin
$sql='select count(*) as count, searchkeywords 
from searchkeywords 
group by searchkeywords 
having searchkeywords LIKE searchkeywords
order by count desc'


Ir this does not work for you explore the HAVING CLAUSE





-Original Message-
From: Rick Dwyer [mailto:rpdw...@earthlink.net] 
Sent: Thursday, April 26, 2012 8:23 PM
To: PHP-General
Subject: [PHP] Insert group by

Hello all.

This is more of a MySQL question, but I'm hoping it can be answered here.
On one of my pages, I issue a SQL command to group data as such:

$sql='select count(*) as count, searchkeywords from searchkeywords group by
searchkeywords order by count desc'

Works well... but I would like it to groups plurals with singular words as
well.  So hats are grouped with hat.

Since I'm doing a group by column name, I don't know that this can be
done.

Any help is appreciated.

Thanks,
 
 --Rick



--
PHP General Mailing List (http://www.php.net/) To unsubscribe, visit:
http://www.php.net/unsub.php


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php