quick query question

Discussion in 'Microsoft Certification' started by John, Nov 11, 2009.

  1. John

    John Guest

    I have a query that I am trying to run, but it is not giving me any results
    at the end of teh query I say .... where (tblManifest.Comment = 'AP
    TRANSPORT') I get zero results, but when I say ....where where
    (tblManifest.Comment = 'RDF') it works just fine. I'm sure it has to do
    with the space in the name. I also know that it would show results.

    Thanks
     
    John, Nov 11, 2009
    #1
    1. Advertisements

  2. John

    John Guest

    also, how would i do it for the query to display results from both?
     
    John, Nov 11, 2009
    #2
    1. Advertisements

  3. If the actual database column value has a space (and only one space), then
    'AP TRANSPORT' should be matched.

    The query engine recognizes spaces as spaces.

    To test the query, you could use wildcard replacement for the space,
    'AP%TRANSPORT', which would then pull any value starting with "AP" and
    ending with "TRANSPORT" and you could observe the actual value(s) in the
    table and match your final query appropriately.


    --
    Lawrence Garvin, M.S., MCITP:EA, MCDBA
    Principal/CTO, Onsite Technology Solutions, Houston, Texas
    Microsoft MVP - Software Distribution (2005-2009)

    My Blog: http://onsitechsolutions.spaces.live.com
    Microsoft WSUS Website: http://www.microsoft.com/wsus
    My MVP Profile: http://mvp.support.microsoft.com/profile/Lawrence.Garvin
     
    Lawrence Garvin [MVP], Nov 11, 2009
    #3

  4. WHERE tblManifest.Comment = 'AP TRANSPORT' OR tblManifest.Comment = 'RDF'

    alternatively you could provide a list

    WHERE tblManifest.Comment IN ('AP TRANSPORT', 'RDF')


    One other note: Usually a 'Comment' field contains extensive amounts of
    text, not discrete string values. Note that you cannot use a WHERE = or
    WHERE IN filter to search for occurrences of substrings in a Comment file,
    unless you appropriately surround the substring definition with wildcards,
    so WHERE tbl.Manifest.Comment = '%AP TRANSPORT%' would match the occurrence
    of the string 'AP TRANSPORT' in the Comment field.

    Beyond that explanation, for further assistance with developing queries, I
    suggest you seek out an Access or SQL Server Programming forum, rather than
    this Microsoft Certification forum.

    --
    Lawrence Garvin, M.S., MCITP:EA, MCDBA
    Principal/CTO, Onsite Technology Solutions, Houston, Texas
    Microsoft MVP - Software Distribution (2005-2009)

    My Blog: http://onsitechsolutions.spaces.live.com
    Microsoft WSUS Website: http://www.microsoft.com/wsus
    My MVP Profile: http://mvp.support.microsoft.com/profile/Lawrence.Garvin
     
    Lawrence Garvin [MVP], Nov 11, 2009
    #4
    1. Advertisements

Ask a Question

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

You'll need to choose a username for the site, which only take a couple of moments (here). After that, you can post your question and our members will help you out.