473,624 Members | 2,394 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

getting url roots

I have a table with a collection of links. For simple duplicates I can check
with an index. But I want also check for more than one link from the same
domain.

So I tried the following:

SELECT name,count(*) AS dcount, SUBSTRING(url,0 ,(LOCATE('/', url,9))) AS
urlroot FROM complink GROUP BY urlroot

The problem I have is that "SUBSTRING(url, 0,(LOCATE('/', url,9)))" does not
work as desired: it always gives the same empty string. So I suspect that
the LOCATE in this position does not work and returns 0.

I would like to get some advise on:
- what goes wrong here
- how I can get the desired effect

Thanks,
Wim
Jul 20 '05 #1
2 1357
Wim Roffal wrote:
I have a table with a collection of links. For simple duplicates I can check
with an index. But I want also check for more than one link from the same
domain.

So I tried the following:

SELECT name,count(*) AS dcount, SUBSTRING(url,0 ,(LOCATE('/', url,9))) AS
urlroot FROM complink GROUP BY urlroot

The problem I have is that "SUBSTRING(url, 0,(LOCATE('/', url,9)))" does not
work as desired: it always gives the same empty string. So I suspect that
the LOCATE in this position does not work and returns 0.


Don't suspect, test it to find out. Broke your large query into smaller
peaces to see how those work, like this:

mysql> select locate('/', 'http://www.google.com/', 9);
+------------------------------------------+
| locate('/', 'http://www.google.com/', 9) |
+------------------------------------------+
| 22 |
+------------------------------------------+
1 row in set (0.00 sec)

mysql> select SUBSTRING('http ://www.google.com/',0,22);
+------------------------------------------+
| SUBSTRING('http ://www.google.com/',0,22) |
+------------------------------------------+
| |
+------------------------------------------+
1 row in set (0.00 sec)

mysql> select SUBSTRING('http ://www.google.com/',1,22);
+------------------------------------------+
| SUBSTRING('http ://www.google.com/',1,22) |
+------------------------------------------+
| http://www.google.com/ |
+------------------------------------------+
1 row in set (0.00 sec)
And at this point, you should see what was wrong ;)
Jul 20 '05 #2
Hi Aggro,

Thanks for the tip!

Wim

"Aggro" <sp**********@y ahoo.com> schreef in bericht
news:q_******** *****@read3.ine t.fi...
Wim Roffal wrote:
I have a table with a collection of links. For simple duplicates I can check with an index. But I want also check for more than one link from the same domain.

So I tried the following:

SELECT name,count(*) AS dcount, SUBSTRING(url,0 ,(LOCATE('/', url,9))) AS
urlroot FROM complink GROUP BY urlroot

The problem I have is that "SUBSTRING(url, 0,(LOCATE('/', url,9)))" does not work as desired: it always gives the same empty string. So I suspect that the LOCATE in this position does not work and returns 0.


Don't suspect, test it to find out. Broke your large query into smaller
peaces to see how those work, like this:

mysql> select locate('/', 'http://www.google.com/', 9);
+------------------------------------------+
| locate('/', 'http://www.google.com/', 9) |
+------------------------------------------+
| 22 |
+------------------------------------------+
1 row in set (0.00 sec)

mysql> select SUBSTRING('http ://www.google.com/',0,22);
+------------------------------------------+
| SUBSTRING('http ://www.google.com/',0,22) |
+------------------------------------------+
| |
+------------------------------------------+
1 row in set (0.00 sec)

mysql> select SUBSTRING('http ://www.google.com/',1,22);
+------------------------------------------+
| SUBSTRING('http ://www.google.com/',1,22) |
+------------------------------------------+
| http://www.google.com/ |
+------------------------------------------+
1 row in set (0.00 sec)
And at this point, you should see what was wrong ;)

Jul 23 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
19391
by: Hal Vaughan | last post by:
I've seen install programs that search a hard drive for previous instances of a program, or to find installs of other needed programs. I need to search a hard drive for any installations of OpenOffice. I know in *nix I can start by using "/" as the file name and doing a recursive listing of the file system from there. (Yes -- I know about permissions to read directories -- that's another issue I've already solved.) How do I find the...
303
17572
by: mike420 | last post by:
In the context of LATEX, some Pythonista asked what the big successes of Lisp were. I think there were at least three *big* successes. a. orbitz.com web site uses Lisp for algorithms, etc. b. Yahoo store was originally written in Lisp. c. Emacs The issues with these will probably come up, so I might as well mention them myself (which will also make this a more balanced
3
1786
by: Richard Hollenbeck | last post by:
I'm sure there's a good explanation, but I haven't seen it in any of the documentation. When I query the mysql database in the user table I see two roots--one with the host as "localhost" and the other with the host as "linux.site." I suppose this is normal, but I don't understand why. This is sort of a repost from yesterday, but since then I reinstalled linux from scratch (SUSE 9.2 pro) I haven't yet added any users or set any...
5
3204
by: Justin Caldicott | last post by:
Hi There are n solutions to the nth root of any number, eg: (-8)^(1/3) = 1 + sqrt(3)i or -2 or 1 - sqrt(3)i The following code:
2
620
by: temper3243 | last post by:
Hi, I have been trying to solve the problem Roots of the polynomial 038 from mipt.ru (el judge). I have failed to do so. I tried to search on the net but found about contour integrals for routh-hurwitz criterion. So it is difficult to code. Can you please tell me how to solve the problem for degree 20 ? and how to approach the problem for degree 4. Please do tell me the pseudo code and references.
3
2205
by: Carl Johansen | last post by:
I have a big ASP website (used by several thousand car dealers) that is a collection of lots of small and medium-sized applications. Now I want to start adding ASP.NET applications to it. I have read Q307467 (How To Create an ASP.NET Application from Multiple Projects for Team Development) and it seems to work well. I understand that when you create a web project in VS.NET, it creates an IIS application root, and that you can remove this...
8
22529
by: aruna | last post by:
to write a c program to find the roots of the equation using bisection method that too using array or pointers
2
2028
by: =?ISO-8859-1?Q?Sch=FCle_Daniel?= | last post by:
Hello NG, given this call to roots funtion from pylab In : roots() Out: array() as far as I understand it stands for a0+a1*x+a2*x^2 in the above case it yields 2x^2+2x = 2x(1+x) and the roots are 0 and -1
1
2997
by: candacefaye1 | last post by:
1. write a C++ program to decide if the coefficients of a quadratic equation have real roots. The three choices will be to write the message “zero divide” when A is zero, write the message “no real roots” if the discriminant is negative and find the two roots when there is no error condition. DO NOT FIND THE ROOT IF THERE IS AN ERROR CONDITION. 2. use a NESTED DECISION to do the three parts of the algorithm above. 3. write a...
2
3133
by: Peng Yu | last post by:
Hi, I have the following program which computes roots of a cubic function. The solution is sensitive to the type, which is due to the truncation error. 'long double T' gives three solutions, and 'typedef double T' gives one solutions. The correct number of solutions should be two, 1 and 2. I know there is some trick to reduce the chance of under or overflow. For example, std::abs(z) shall be implemented as
0
8240
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8175
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
8680
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
8625
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
8336
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8482
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
4082
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
1
1791
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
2
1487
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.