Sunday, February 19, 2012

Counting the occurence of a string ...

Hi ...
I have a weblog database where I want to count the occurences of a
table of string values that appear in all the urls viewed.

My tblWebLog as a field that contains the url ...
tblWebLog.[cs-uri-stem]

I have another table ... tblStrings ... that has a field [strSearch]
for a string value and an integer field [intViewCount] to count the
occurence of the string in tblWebLog.[cs-uri-stem]

I've been trying ...

Update tblStrings
Set [intViewCount] = (Select Count(*) From tblWebLog Where
[cs-uri-stem] Like '%_' + tblStrings.[strSearch] + '.htm%')

... but it doesn't fly and I'm stumped. Any thoughts?

Cheers.DaFerg (dave@.myalarm.com) writes:

Quote:

Originally Posted by

I have a weblog database where I want to count the occurences of a
table of string values that appear in all the urls viewed.
>
My tblWebLog as a field that contains the url ...
tblWebLog.[cs-uri-stem]
>
I have another table ... tblStrings ... that has a field [strSearch]
for a string value and an integer field [intViewCount] to count the
occurence of the string in tblWebLog.[cs-uri-stem]
>
I've been trying ...
>
Update tblStrings
Set [intViewCount] = (Select Count(*) From tblWebLog Where
[cs-uri-stem] Like '%_' + tblStrings.[strSearch] + '.htm%')
>
... but it doesn't fly and I'm stumped. Any thoughts?


Your query make sense in relation to your description, but then again I
may be misunderstanding something.

For this sort of question, it helps if you post:

o CREATE TABLE statements for your tables.
o INSERT statements with sample data.
o The desired result given the sample.

This helps to clarify what you are looking for, and it makes it possible
to copy and paste and develop a tested solution.

--
Erland Sommarskog, SQL Server MVP, esquel@.sommarskog.se
Books Online for SQL Server 2005 at
http://www.microsoft.com/technet/pr...oads/books.mspx
Books Online for SQL Server 2000 at
http://www.microsoft.com/sql/prodin...ions/books.mspx|||If tblStrings.[strSearch] is defined as fixed length (char) instead of
varying length (varchar) that would cause problems. Or if trailing
blanks were stored in a varchar column. Try using
RTRIM(tblStrings.[strSearch]) instead.

Roy Harvey
Beacon Falls, CT

On 27 Aug 2006 01:00:04 -0700, "DaFerg" <dave@.myalarm.comwrote:

Quote:

Originally Posted by

>Hi ...
>I have a weblog database where I want to count the occurences of a
>table of string values that appear in all the urls viewed.
>
>My tblWebLog as a field that contains the url ...
>tblWebLog.[cs-uri-stem]
>
>I have another table ... tblStrings ... that has a field [strSearch]
>for a string value and an integer field [intViewCount] to count the
>occurence of the string in tblWebLog.[cs-uri-stem]
>
>I've been trying ...
>
>Update tblStrings
>Set [intViewCount] = (Select Count(*) From tblWebLog Where
>[cs-uri-stem] Like '%_' + tblStrings.[strSearch] + '.htm%')
>
>... but it doesn't fly and I'm stumped. Any thoughts?
>
>Cheers.

No comments:

Post a Comment