Results 1 to 5 of 5
  1. #1
    Join Date
    Mar 2004
    Location
    Washington State
    Posts
    2

    Unanswered: Another n00b select statement problem...

    When I try to use this select statement:

    SELECT main.title, main.URL, main.description, main.city FROM main ORDER BY city WHERE (((main.active)=True));

    I get a: Syntax error (missing operator) in query expression 'city WHERE (((main.active)=True))'

    But, if I try this:

    SELECT main.title, main.URL, main.description, main.city FROM main WHERE (((main.active)=True));

    or this:

    SELECT main.title, main.URL, main.description, main.city FROM main ORDER BY city;

    They both work as expected. How do I combine them effectively?




    Also, when I try the select statement below:

    SELECT main.title, main.url, main.description, main.city
    FROM main
    WHERE (((main.category)="educ") AND ((main.category_2)="elem") AND ((main.active)=True));

    I get a: Unterminated string constant Error (probably because of the double quotes?)

    So how can this one be formatted to work without the quotes? (I have tried just removing them to no avail)


    Thank You for your help. I am very happy to have found this resource (even though I couldn't find a thread with a solution to a similar problem)

  2. #2
    Join Date
    Apr 2002
    Location
    Toronto, Canada
    Posts
    20,002
    for your first problem, ORDER BY must follow WHERE

    for your second problem the string delimiter is the single quote, not the double quote
    rudy.ca | @rudydotca
    Buy my SitePoint book: Simply SQL

  3. #3
    Join Date
    Mar 2004
    Location
    Washington State
    Posts
    2
    Originally posted by r937
    for your first problem, ORDER BY must follow WHERE

    for your second problem the string delimiter is the single quote, not the double quote
    Thank you, first problem solved (Order of operations did the trick)

    However, the second problem remains:

    rs.Open "SELECT main.title, main.url, main.description, main.city
    FROM main
    WHERE (((main.category_2)='elem'));", conn%>

    When you said the string delimiter is the single quote, I am assuming that means to bracket the elem by single quotes instead of double. The above select statement still gives me a Unterminated string constant error.

  4. #4
    Join Date
    Apr 2002
    Location
    Toronto, Canada
    Posts
    20,002
    rudy.ca | @rudydotca
    Buy my SitePoint book: Simply SQL

  5. #5
    Join Date
    Sep 2002
    Location
    UK
    Posts
    5,171
    Provided Answers: 1
    Could this be because you are using VBScript which requires end of line continuation markers something more like this? :-

    rs.Open "SELECT main.title, main.url, main.description, main.city" _
    & " FROM main" _
    & " WHERE (((main.category_2)='elem'));", conn%>

Posting Permissions

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