WebProWorld Part of WebProNews.com
Page One Link To Us Edit Profile Private Messages Archives FAQ RSS Feeds  
 

Go Back   WebProWorld > Webmaster, IT and Security Discussion > Database Discussion Forum
Subscribe to the Newsletter FREE!


Register FAQ Members List Calendar Arcade Chatbox Mark Forums Read

Database Discussion Forum This is the place to find help resolving those nagging questions you have about implementing and using all kinds of databases. Need help writing a query? Need an opinion on Oracle? Post here!

Reply
 
LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 10-16-2004, 05:25 AM
WebProWorld Member
 

Join Date: Sep 2004
Location: Northampton, UK
Posts: 41
profilesite RepRank 0
Default MySQL Question

i've got a table full of websites and i want to group them by the domain name, eg.. some are listed as www.domain.com and some as www.domain.com/blah. I want to group them to show the most popular domain, any ideas?
Reply With Quote
  #2 (permalink)  
Old 10-16-2004, 05:32 AM
WebProWorld Pro
 

Join Date: May 2004
Location: United Kingdom
Posts: 176
php~pro RepRank 0
Default

Add either a user rating feature or just add a field for a count figure next to the url field. Write a small function to update the relevant count by 1 each time the link is clicked. To show the most popular results query the db for results with the new field count desc.
Reply With Quote
  #3 (permalink)  
Old 10-16-2004, 05:43 AM
WebProWorld Member
 

Join Date: Sep 2004
Location: Northampton, UK
Posts: 41
profilesite RepRank 0
Default

hi, thanks for replying. that is the system i have in place already, what i am looking to do is find the most popular domain, rather than most popular individual link. I imagine what i need is a group by with some string function to strip the domain name out of the URL field, so stats for www.domain.com/link2 and www.domain.com/link2 would be grouped. hope that makes sense.
Reply With Quote
  #4 (permalink)  
Old 11-16-2004, 11:23 PM
godzilla's Avatar
WebProWorld Member
 

Join Date: Aug 2003
Location: Montreal, CA
Posts: 68
godzilla RepRank 0
Default

I haven't found a way to strip strings in sql... unfortunately. if any one does please post it here!!
__________________
Everything has its reason.
Your greatest glory doesn't consist in falling, but rising every time you fall and this is what defines a perfect human.
Godzilla's pass-time
Reply With Quote
  #5 (permalink)  
Old 11-17-2004, 04:46 AM
WebProWorld Pro
 

Join Date: Nov 2004
Posts: 144
rivux RepRank 0
Default

I've done this two different ways, one is to have a script that runs on a nightly basis and summarizes the tracking data which allows me to order by domain. This is all done in php and requires and extra table to hold the summarized data.

To do it on the fly so to speak, you can try using a rather ugly and brutal query I wrote.

Code:
select count(referrer) as refcount, referrer, Left(referrer, LOCATE('/',referrer, LOCATE('/',referrer, LOCATE('/',referrer, LOCATE('/',referrer,0)+1)+1)+1)) as domainref from tracksection group by Left(referrer, LOCATE('/',referrer, LOCATE('/',referrer, LOCATE('/',referrer, LOCATE('/',referrer,0)+1)+1)+1)) having (referrer Not Like '%mydomain.com%' AND referrer != '') order by refcount desc
If you replace 'referrer' with the field that holds your domain info and 'tracksection' with your table name, then the query should work. I know its rather ugly looking but it gets the job done in a pinch. lol I also have the mydomain.com in there in case your domains are listed (if you track internal pages as well) and you wish to weed them out. If you don't need this you can just take out the entire 'having ...' section.
Reply With Quote
  #6 (permalink)  
Old 11-17-2004, 07:34 AM
WebProWorld New Member
 

Join Date: Oct 2004
Posts: 18
Amitkrathi RepRank 0
Default

Clean urls with php parse_url() function & then store in temporary table & then retrieve records from temporary table with group by clause to get most popular domains.
__________________
Amit Rathi
http://www.sphereinfo.com
Reply With Quote
Reply

  WebProWorld > Webmaster, IT and Security Discussion > Database Discussion Forum
Tags: ,



Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Search Engine Optimization by vBSEO 3.2.0