Reply
Using TRIM in mysql?
Old 08-22-2006, 01:21 PM Using TRIM in mysql?
Novice Talker

Posts: 9
My problem is as follows:

I want to display a list grouped by the domain part of the URL from my webblog of referers. Is this possible using sql?

Example of values from the URL field:
h t t p://www.google.com/search?hl=en&lr=&q=Freeroll+Tracker
h t t p://www.google.com/search?hl=en&lr=&q=poker+tournament+tracker+sit+an d+go
h t t p://www.google.bg/search?hl=bg&q=nordicbet+bonus+code&btnG=Google+%D 0%A2%D1%8A%D1%80%D1%81%D0%B5%D0%BD%D0%B5&meta

Should give the result:
h t t p://www.google.com/ 2 hits
h t t p://www.google.bg/ 1 hit

Hope this makes sense =)
__________________
Webmaster of http://poker.vcfrontline.com

Last edited by vcfrontline : 08-22-2006 at 01:28 PM. Reason: Stupid autoformat of URLs =)
vcfrontline is offline
Reply With Quote
View Public Profile
 
When You Register, These Ads Go Away!
Old 08-23-2006, 12:20 AM Re: Using TRIM in mysql?
mgraphic's Avatar
Truth Seeker

Latest Blog Post:
Converting Video For YouTube
Posts: 2,337
Name: Keith Marshall
Location: West Hartford, CT
You can use regular expressions in mysql to match a pattern. I came up with the following, but its untested.

Code:
SELECT *, url REGEXP "/^https?:\/\/(www\.)?[^\.\/]*\.[^\.\/]{2,4}\/.*$/i" AS match FROM table_name GROUP BY match
__________________

<mgraphic /> - I don't have a solution but I admire the problem.

Last edited by mgraphic : 08-23-2006 at 12:21 AM.
mgraphic is offline
Reply With Quote
View Public Profile
 
Old 08-23-2006, 12:45 PM Re: Using TRIM in mysql?
Novice Talker

Posts: 9
Thanks for your response after changing MATCH to another Word it works in some way which means i get a selection atleast, not what I want but something atleast =)

Can you please explain the code a bit so that I can figure out how to use it so I get the response I want.

Thanks for taking the time with this
__________________
Webmaster of http://poker.vcfrontline.com
vcfrontline is offline
Reply With Quote
View Public Profile
 
Old 08-23-2006, 12:54 PM Re: Using TRIM in mysql?
mgraphic's Avatar
Truth Seeker

Latest Blog Post:
Converting Video For YouTube
Posts: 2,337
Name: Keith Marshall
Location: West Hartford, CT
Code:
SELECT *, url REGEXP "/^https?:\/\/(www\.)?[^\.\/]*\.[^\.\/]{2,4}\/.*$/i" AS match FROM table_name GROUP BY match
Select all and url column that matches http (or https)://www. (or no www) blah . com (or other extention between 2 and 4 chars) / case insenstive - name result as match from the table selected and group by our match result
__________________

<mgraphic /> - I don't have a solution but I admire the problem.
mgraphic is offline
Reply With Quote
View Public Profile
 
Old 08-23-2006, 02:50 PM Re: Using TRIM in mysql?
Novice Talker

Posts: 9
Thanks again.

Forgot to mention in the previous post that the result i get in the MATCH variable is either 0 or Null. What I really want as result is the domain names neatly grouped from the log.
__________________
Webmaster of http://poker.vcfrontline.com
vcfrontline is offline
Reply With Quote
View Public Profile
 
Old 08-23-2006, 09:42 PM Re: Using TRIM in mysql?
mgraphic's Avatar
Truth Seeker

Latest Blog Post:
Converting Video For YouTube
Posts: 2,337
Name: Keith Marshall
Location: West Hartford, CT
Yea - I guess that it does return a boolean instead of a match, and I don't know how you can use the regexp references in a sql command. I don't have any other suggestions right off hand, sorry.
__________________

<mgraphic /> - I don't have a solution but I admire the problem.
mgraphic is offline
Reply With Quote
View Public Profile
 
Old 08-24-2006, 04:24 AM Re: Using TRIM in mysql?
Novice Talker

Posts: 9
Thanks for taking the time trying to solve my problem.
__________________
Webmaster of http://poker.vcfrontline.com
vcfrontline is offline
Reply With Quote
View Public Profile
 
Old 08-25-2006, 11:41 AM Re: Using TRIM in mysql?
saadatshah's Avatar
Extreme Talker

Posts: 216
Name: Syed Saadat Ali
Location: Lahore, Pakistan
Useful post
__________________
Traffic School - Driver Ed - Defensive Driving - Texas Defensive Driving - Online Traffic School - Defensive Driving Course
If you have knowledge, let others light their candles in it.
saadatshah is offline
Reply With Quote
View Public Profile Visit saadatshah's homepage!
 
Old 08-25-2006, 03:27 PM Re: Using TRIM in mysql?
Novice Talker

Posts: 9
Couldnt solve my problem just using SQL so I split the string at insertion instead into its own field so now I can retrieve what I want using an ordinary GROUP BY selection =).

Thanks for the help trying to solve my initial problem.
__________________
Webmaster of http://poker.vcfrontline.com
vcfrontline is offline
Reply With Quote
View Public Profile
 
Reply     « Reply to Using TRIM in mysql?
 

Thread Tools

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 Off
Pingbacks are Off
Refbacks are Off




   
RSS Feed  Feeds: RSS   JS   XML
RSS Feed  Feeds for this forum: RSS   JS   XML

 


Page generated in 0.15213 seconds with 12 queries