0
table links
id       url
 1       http://www.domain.hk/index.php?main_page=index&cPath=8
 3       http://www.domain.com/index.php?main_page=index&cPath=3
 6       http://www.domain.com/index.php?main_page=index&cPath=8
 8       http://www.domain.hk/index.php?main_page=index&cPath=7&language=tc
 9       http://www.domain.com/index.php?main_page=index&cPath=3

How to count number of same cPath id and number of same cPath id's domain from field url use regex ?

I want the results like this:

cPath : 8 total: 2 hk: 1 com : 1

cPath : 3 total: 2 com : 2

cPath : 7 total: 1 com : 1

Thanks a lot.

1
  • mind to fix all the typo first? Commented Jan 11, 2011 at 9:41

1 Answer 1

1

I don't think I have enough knowledge to generate hk:1, com:1

but this is closer I can generate

select 
  substring_index(substring_index(url, 'cPath=', -1), '&', 1) as cpath, 
  count(*) as total, 
  substring_index(substring_index(url, '/', 3), '.', -1) as tld 
from links 
group by cpath, tld;
| cpath | count(*) | tld  |
+-------+----------+------+
| 3     |        2 | com  |
| 7     |        1 | hk   |
| 8     |        1 | com  |
| 8     |        1 | hk   |
+-------+----------+------+

PS hk,com is not domain name but TLD

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.