Re: GROUP_CONCAT query

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

 



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` ,
`timelength`
FROM `webstatstable`"


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@xxxxxx *
*************************************


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


[Index of Archives]     [PHP Home]     [PHP Users]     [Postgresql Discussion]     [Kernel Newbies]     [Postgresql]     [Yosemite News]

  Powered by Linux