Velocity Reviews

Velocity Reviews (http://www.velocityreviews.com/forums/index.php)
-   ASP General (http://www.velocityreviews.com/forums/f65-asp-general.html)
-   -   "query contains" help please (http://www.velocityreviews.com/forums/t792793-query-contains-help-please.html)

David 01-20-2004 04:23 PM

"query contains" help please
 
Hi,

I'd like to adapt the query below to select records only if the Title field
contains the string "Book" (as an example).

I'd also like to use a different variant of the query elsewhere to select
all records where the Title field does not contain the string "Book".

I know my question sounds dumb to many, but I haven't worked with .ASP in a
while, and don't know how to put "Contains" and "Doesn't contain" in a
query, and can't seem to find this info easily at aspin.com

Many thanks for assistance.

David

set rsData = MyConn.execute("select URL,Counter,Title from HitTable ORDER BY
Counter DESC")
arData = rsData.getrows



Ray at 01-20-2004 04:26 PM

Re: "query contains" help please
 

"David" <david@brown6669.freeserve.co.uk> wrote in message
news:%BcPb.156$9b5.45@newsfep3-gui.server.ntli.net...
> Hi,
>
> I'd like to adapt the query below to select records only if the Title

field
> contains the string "Book" (as an example).


What kind of database?

select URL,Counter,Title from HitTable WHERE Title LIKE '%Book%' ORDER BY
Counter DESC




> I'd also like to use a different variant of the query elsewhere to select
> all records where the Title field does not contain the string "Book".


select URL,Counter,Title from HitTable WHERE Title NOT LIKE '%Book%' ORDER
BY Counter DESC



>
> I know my question sounds dumb to many, but I haven't worked with .ASP in

a
> while, and don't know how to put "Contains" and "Doesn't contain" in a
> query, and can't seem to find this info easily at aspin.com


It's not dumb!

Ray at work



Alex Goodey 01-20-2004 04:32 PM

Re: "query contains" help please
 
This is more to do with T-SQL statements rather than asp, to have a
condition where a string must contain somethin you use LIKE

set rsData = MyConn.execute("select URL,Counter,Title from HitTable WHERE
Title LIKE '%Book%' ORDER BY Counter DESC")

The % marks around Book, state that Book can be located anywhere in the
string so a book called aaaaBookaaa would be returned as would aaaaBook and
Bookaaa

If you left out the preceding % like this 'Book%' then only 'Bookaaa' would
be returned

"David" <david@brown6669.freeserve.co.uk> wrote in message
news:%BcPb.156$9b5.45@newsfep3-gui.server.ntli.net...
> Hi,
>
> I'd like to adapt the query below to select records only if the Title

field
> contains the string "Book" (as an example).
>
> I'd also like to use a different variant of the query elsewhere to select
> all records where the Title field does not contain the string "Book".
>
> I know my question sounds dumb to many, but I haven't worked with .ASP in

a
> while, and don't know how to put "Contains" and "Doesn't contain" in a
> query, and can't seem to find this info easily at aspin.com
>
> Many thanks for assistance.
>
> David
>
> set rsData = MyConn.execute("select URL,Counter,Title from HitTable ORDER

BY
> Counter DESC")
> arData = rsData.getrows
>
>




David 01-20-2004 08:59 PM

Re: "query contains" help please
 
Thanks for the help guys - works great!

David




All times are GMT. The time now is 02:55 PM.

Powered by vBulletin®. Copyright ©2000 - 2014, vBulletin Solutions, Inc.
SEO by vBSEO ©2010, Crawlability, Inc.