Re: GROUP_CONCAT query
| From: | Rui Cunha | Date: | Fri, 11 Jun 2004 16:54:55 +0000 |
| Subject: | Re: GROUP_CONCAT query | ||
| References: | 1 | Groups: | php.db |
| Request: | Send a blank email to php-db+get-34745@lists.php.net to get a copy of this message | ||
i presume you want something like:
select ip,hostname,referer,count(*)
from table
group by ip,hostname,referer;
note: all fields in the select clause that are not affected by any aggregate function must appear in the group by clause;
I.A. Gray writes:
Hi all, I sometimes find the MYSQL manual very difficult to understand- perhaps I am alone in this. I am wanting to do the following, and I think I need to use GROUP_CONCAT in my query. I have a table of webstats for my site with columns for IP, Hostname, referer website etc and I want to show the occurences of the the same IP, hostname and referer website and how many times. How do I do this? My normal query would look like this? $query = "SELECT*************************************id,clicks,os,browser,ip,port,host,country_code,country_name,cookies,crawler,referer_website,qs,datestart,dateend,timestart,timeend,history,fulltimestart,daystart,fulltimeend,dayend,timelengthFROMwebstatstable" I have tried doing SELECT referer_website, GROUP_CONCAT(referer_website) FROM 'webstatstable' but that doesn't seem to work. Any ideas?
* Rui Pedro Cunha ** Dpto. de Ciências e Tecnologias * * Universidade Autónoma de Lisboa *
* Rua de Santa Marta, 56, * * 1169-023 Lisboa ** Telefone (+351) 21 317 76 35/49 *
* Fax (+351) 21 353 37 02 * * Url : http://www.ual.pt/dct/ * * E-mail: rui.cunha@ual.pt * *************************************