PHWinfo banniere

Titres
PORTAIL ANNUAIRE ARTICLES COMPARATEUR HÉBERGEURS DEVIS FORUMS RÉDUCTEUR D'URL
Précédent   PHWinfo > Forums Hébergement > Forum Logiciels d'hébergement > mailing.database.mysql > creating a url distribution report
S'inscrire FAQ Membres Recherche Messages du jour Marquer les forums comme lus
creating a url distribution report

Réponse
 
LinkBack Outils de la discussion
Vieux 24/06/2006, 01h26   #1
nakkaya@gmail.com
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut creating a url distribution report

i have the following table in my application

CREATE TABLE `documentList` (
`id` INT UNSIGNED NOT NULL auto_increment,
`document` varchar(255) NOT NULL,
`archiveDate` date,
`contentType` varchar(30),
`resultCode` varchar(30),
`size` MEDIUMINT UNSIGNED ,
`title` varchar(200) ,
UNIQUE KEY `document_unique_key` (`document`),
PRIMARY KEY (`id`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8 COMMENT='list document urls..';

i want to create a list of unique host and how many documents it has in
the table from url
if i have following in the table

http://www.linux.org:80/
http://www.linux.org:80/xyz.html

i want to produce

host url count
http://www.linux.org | 2

i tried it with regex but i can only list unique host but cant count
them is there way to accoplish this?

  Réponse avec citation
Vieux 24/06/2006, 02h47   #2
Bill Karwin
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: creating a url distribution report

nakkaya@gmail.com wrote:
> http://www.linux.org:80/
> http://www.linux.org:80/xyz.html
>
> i want to produce
>
> host url count
> http://www.linux.org | 2


SQL isn't the most convenient string-manipulation language, compared to
Perl and others, but there are ways to do it:

SELECT LEFT(document, LOCATE('/', document, 8)-1) AS `host`, COUNT(*) AS
`url count`
FROM documentList
GROUP BY host

Regards,
Bill K.
  Réponse avec citation
Vieux 24/06/2006, 05h55   #3
nakkaya@gmail.com
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: creating a url distribution report

works like a charm thanks..

Bill Karwin wrote:
> nakkaya@gmail.com wrote:
> > http://www.linux.org:80/
> > http://www.linux.org:80/xyz.html
> >
> > i want to produce
> >
> > host url count
> > http://www.linux.org | 2

>
> SQL isn't the most convenient string-manipulation language, compared to
> Perl and others, but there are ways to do it:
>
> SELECT LEFT(document, LOCATE('/', document, 8)-1) AS `host`, COUNT(*) AS
> `url count`
> FROM documentList
> GROUP BY host
>
> Regards,
> Bill K.


  Réponse avec citation
Réponse


Outils de la discussion

Règles de messages
Vous ne pouvez pas créer de nouvelles discussions
Vous ne pouvez pas envoyer des réponses
Vous ne pouvez pas envoyer des pièces jointes
Vous ne pouvez pas modifier vos messages

Les balises BB sont activées : oui
Les smileys sont activés : oui
La balise [IMG] est activée : oui
Le code HTML peut être employé : non
Trackbacks are oui
Pingbacks are oui
Refbacks are oui


Fuseau horaire GMT +1. Il est actuellement 11h02.


Édité par : vBulletin® version 3.7.3
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.2.0 RC5 Tous droits réservés.
Version française #16 par l'association vBulletin francophone
PHWinfo est un site Éducation Sans Frontières ©2000-2008
Ad Management by RedTyger
©Tous droits réservés par les parties respectives
Page generated in 0,08347 seconds with 11 queries