SQL Where <> help with syntax

Discussion in 'ASP General' started by iam247@gmail.com, Jul 31, 2005.

  1. Guest

    Hi

    I am fairly inexperienced with ASP, SQL and VB Script.

    In one of my web pages I am trying to search a table in access which
    has a number of integers (GroupID's) (1 to 5 at present) and find those
    which do not match another set of GroupID's already contained in a
    record set named rsGroupsJ (1 to 4 at present).

    I want to find the GroupID's which do not match ie GroupID

    I have created the following sql which returns the error:
    "Unterminated string constant"

    strSQL3 = "SELECT tblGroups.* FROM tblGroups WHERE tblGroups.GroupID <>
    (rsGroupsJ("GroupID"))"

    The following sql does not create an error message but the WHERE bit
    seems to be ignored - it returns all records 1 to 5, it should only
    return 5

    I am realy poor at creating sql statements, I am never sure where or
    why to put " or &

    I have looked at a number of tutorials but cannot find examples close
    to my requirements.

    Any help with this would be appreciated

    ColinK
     
    , Jul 31, 2005
    #1
    1. Advertising

  2. wrote:
    > Hi
    >
    > I am fairly inexperienced with ASP, SQL and VB Script.
    >
    > In one of my web pages I am trying to search a table in access which
    > has a number of integers (GroupID's) (1 to 5 at present) and find
    > those which do not match another set of GroupID's already contained
    > in a record set named rsGroupsJ (1 to 4 at present).
    >
    > I want to find the GroupID's which do not match ie GroupID
    >
    > I have created the following sql which returns the error:
    > "Unterminated string constant"
    >
    > strSQL3 = "SELECT tblGroups.* FROM tblGroups WHERE tblGroups.GroupID
    > <> (rsGroupsJ("GroupID"))"


    Do
    response.write strsql3

    to see the esult of this concatenation.


    >
    > The following sql does not create an error message but the WHERE bit
    > seems to be ignored - it returns all records 1 to 5, it should only
    > return 5


    See above

    >
    > I am realy poor at creating sql statements, I am never sure where or
    > why to put " or &


    Forget concatenation. Create your query in Access and verify that it works.
    That'st the only way to see if you're doing it correctly.

    >
    > I have looked at a number of tutorials but cannot find examples close
    > to my requirements.
    >
    > Any help with this would be appreciated
    >
    > ColinK


    All right, you're depending too much on multiple recordsets, but, here's my
    take on the rule for delimeters:
    http://groups-beta.google.com/group.../713f592513bf333c?hl=en&lr=&ie=UTF-8&oe=UTF-8

    Bob Barrows

    --
    Microsoft MVP - ASP/ASP.NET
    Please reply to the newsgroup. This email account is my spam trap so I
    don't check it very often. If you must reply off-line, then remove the
    "NO SPAM"
     
    Bob Barrows [MVP], Jul 31, 2005
    #2
    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:
    6
    Views:
    471
    Kevin Spencer
    Jun 25, 2007
  2. ecoolone
    Replies:
    0
    Views:
    767
    ecoolone
    Jan 3, 2008
  3. gabriele renzi
    Replies:
    2
    Views:
    207
    gabriele renzi
    Dec 31, 2005
  4. Ken Bloom
    Replies:
    3
    Views:
    215
  5. Good Night Moon
    Replies:
    9
    Views:
    284
    Rick DeNatale
    Jul 25, 2007
Loading...

Share This Page