"query contains" help please

Discussion in 'ASP General' started by David, Jan 20, 2004.

  1. David

    David Guest

    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, Jan 20, 2004
    #1
    1. Advertising

  2. David

    Ray at Guest

    "David" <> wrote in message
    news:%BcPb.156$...
    > 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
    Ray at, Jan 20, 2004
    #2
    1. Advertising

  3. David

    Alex Goodey Guest

    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" <> wrote in message
    news:%BcPb.156$...
    > 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
    >
    >
    Alex Goodey, Jan 20, 2004
    #3
  4. David

    David Guest

    Thanks for the help guys - works great!

    David
    David, Jan 20, 2004
    #4
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Replies:
    4
    Views:
    509
    Chris Uppal
    May 5, 2005
  2. KK
    Replies:
    2
    Views:
    556
    Big Brian
    Oct 14, 2003
  3. MuZZy
    Replies:
    7
    Views:
    1,750
    Mike Hewson
    Jan 7, 2005
  4. Replies:
    9
    Views:
    309
    M.-A. Lemburg
    Jun 4, 2008
  5. mera
    Replies:
    7
    Views:
    1,103
Loading...

Share This Page