Jump to content

Help with a query please


Go to solution Solved by 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.

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.