Jump to content

Help with a query please


desjardins2010

Recommended Posts

I'm trying to structure this query properly but failing with all attempts. 

 

i have a table that has 5 fields id, http_referrer,ip,hit,today

 

what I want to do is query this table to show me all the http_referrer's GROUPED up so only 1 row for ALL say 255 results that came from www.google.ca and the SUM'd hits 

 

so 

 

RFERRER          HIT

google.ca           255

phpfreaks.com   15

 

I tried 

SELECT SUM(hit) as 'hits' FROM `global_stats` GROUP BY `http_referrer`

this don't work

Link to comment
https://forums.phpfreaks.com/topic/287094-help-with-a-query-please/
Share on other sites

Ok this worked BUT one more question regarding this I notice that I get alot of sites that are the same CORE site but different appending ID's so they showing as different sites... is there an easy way to just match the www.something.com and leave our the ?asdfmsdmfs

 

 

just curious no biggy I can handle if not

Ok this worked BUT one more question regarding this I notice that I get alot of sites that are the same CORE site but different appending ID's so they showing as different sites... is there an easy way to just match the www.something.com and leave our the ?asdfmsdmfs

 

 

just curious no biggy I can handle if not

 

You could use RegEx in your query, but that is a sub-optimal solution since RegEx will be slow. Instead, you should handle this when saving the records to your database by stripping off the extraneous bit. If you do need the full URL then you should add a column and put the base URL in one and the parameters of the URL in the other.

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.