SQl Statement

Results 1 to 5 of 5

Thread: SQl Statement

  1. #1
    wini Guest

    Default SQl Statement

    Is there a linit on what is the max no. of "and " you can have in a select statement.<BR>I quering a access database and writing following statement<BR><BR>cmd5.CommandText="Select distinct val5,val4,val3, val2, val1 from testtable where val1= &#039;"& rs4("val1") &"&#039; and val2 = &#039;"& rs4("val2") &"&#039; and val3 = &#039;"& rs4("val3") &"&#039; and val4 = &#039;"& rs4("val4") &"&#039; "<BR><BR>It fails and gives following error<BR><BR>Syntax error (missing operator) in query expression<BR>

  2. #2
    Join Date
    Dec 1969
    Los Angeles, CA

    Default No

    response.write your SQL and check for errors.<BR><BR>

  3. #3
    Join Date
    Dec 1969

    Default RE: SQl Statement

    Each statement needs to stand alone. Use your &#039;" "&#039; around each. Also, that is going to be an incredibly slow piece of code. Is there another way to get what you need?

  4. #4
    Eddie Campbell Guest

    Default RE: SQl Statement

    I think that Access has a maximum length for a SQL statement, but it would not give you the error you are getting.<BR><BR>Try doing a response.write of you SQL statement and see what you get.

  5. #5
    Join Date
    Dec 1969

    Default RE: SQl Statement

    Replace your rs4("")s with hard values. Write it out check for syntax errors.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts