Syntax error (missing operator) in query expression

Discussion in 'ASP General' started by isaac2004, Feb 21, 2006.

  1. isaac2004

    isaac2004 Guest

    hello i am getting a weird al syntax error from my SQL statement

    Microsoft OLE DB Provider for ODBC Drivers error '80040e14'

    [Microsoft][ODBC Microsoft Access Driver] Syntax error (missing
    operator) in query expression 'tblBookDescription.strTitle Where
    (((tblCategories.strCategory) = 'Database'))'.

    /06Winter/levini/A07/SearchBrowse.asp, line 53


    here is my server side code ps. i have already dim strSQL and objRS
    prior

    <% dim strBrowse

    strBrowse = request.querystring("strBrowse")



    'sql statement with random book ids
    strSQL = "SELECT tblCategories.strCategory, tblBookDescription.ISBN,
    tblBookDescription.strTitle, tblBookDescription.strDescription,
    tblAuthorsBooks.AuthorID " & _
    "FROM (tblBookDescription INNER JOIN tblAuthorsBooks ON
    tblBookDescription.ISBN = tblAuthorsBooks.ISBN) INNER JOIN
    tblCategories ON tblBookDescription.ISBN = tblCategories.ISBN " & _
    "ORDER BY tblBookDescription.strTitle "



    'response.write("strSQL = " & strSQL)


    if strBrowse > "" then
    'browse
    strSQL = strSQL & " Where (((tblCategories.strCategory) = '" &
    strBrowse & "')); "
    end if


    response.write("strSQL = " & strSQL)

    Set objRS = Server.CreateObject("ADODB.Recordset")

    --------------------------------------------------------------error
    here
    objRS.open strSQL, objConn
    -----------------------------------------------------------------

    %>

    my response write outputs

    strSQL = SELECT tblCategories.strCategory, tblBookDescription.ISBN,
    tblBookDescription.strTitle, tblBookDescription.strDescription,
    tblAuthorsBooks.AuthorID FROM (tblBookDescription INNER JOIN
    tblAuthorsBooks ON tblBookDescription.ISBN = tblAuthorsBooks.ISBN)
    INNER JOIN tblCategories ON tblBookDescription.ISBN =
    tblCategories.ISBN ORDER BY tblBookDescription.strTitle Where
    (((tblCategories.strCategory) = 'Database'));

    thanx for the help
    isaac2004, Feb 21, 2006
    #1
    1. Advertising

  2. isaac2004 wrote:
    >
    > my response write outputs
    >
    > strSQL = SELECT tblCategories.strCategory, tblBookDescription.ISBN,
    > tblBookDescription.strTitle, tblBookDescription.strDescription,
    > tblAuthorsBooks.AuthorID FROM (tblBookDescription INNER JOIN
    > tblAuthorsBooks ON tblBookDescription.ISBN = tblAuthorsBooks.ISBN)
    > INNER JOIN tblCategories ON tblBookDescription.ISBN =
    > tblCategories.ISBN ORDER BY tblBookDescription.strTitle Where
    > (((tblCategories.strCategory) = 'Database'));
    >


    What happens when you open your database in Access, paste this sql statement
    into the SQL View of a Query Builder, and try to run it?

    --
    Microsoft MVP -- ASP/ASP.NET
    Please reply to the newsgroup. The email account listed in my From
    header is my spam trap, so I don't check it very often. You will get a
    quicker response by posting to the newsgroup.
    Bob Barrows [MVP], Feb 21, 2006
    #2
    1. Advertising

  3. isaac2004 wrote:
    > hello i am getting a weird al syntax error from my SQL statement
    >


    >
    > my response write outputs
    >
    > strSQL = SELECT tblCategories.strCategory, tblBookDescription.ISBN,
    > tblBookDescription.strTitle, tblBookDescription.strDescription,
    > tblAuthorsBooks.AuthorID FROM (tblBookDescription INNER JOIN
    > tblAuthorsBooks ON tblBookDescription.ISBN = tblAuthorsBooks.ISBN)
    > INNER JOIN tblCategories ON tblBookDescription.ISBN =
    > tblCategories.ISBN ORDER BY tblBookDescription.strTitle Where
    > (((tblCategories.strCategory) = 'Database'));
    >
    > thanx for the help

    Actually, it's not a weird error at all: it's the error one should expect to
    get when trying to put the WHERE clause after the ORDER BY clause.
    The clauses need to be in the correct order:
    SELECT ...
    FROM ...
    WHERE ...
    GROUP BY ...
    HAVING ...
    ORDER BY ...

    Bob Barrows
    --
    Microsoft MVP -- ASP/ASP.NET
    Please reply to the newsgroup. The email account listed in my From
    header is my spam trap, so I don't check it very often. You will get a
    quicker response by posting to the newsgroup.
    Bob Barrows [MVP], Feb 21, 2006
    #3
    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. D
    Replies:
    4
    Views:
    2,283
  2. D
    Replies:
    0
    Views:
    2,235
  3. alexz
    Replies:
    0
    Views:
    114
    alexz
    Jul 11, 2003
  4. Maciej Paras
    Replies:
    1
    Views:
    158
    Bob Barrows
    Oct 30, 2003
  5. shank
    Replies:
    26
    Views:
    382
    Bob Barrows [MVP]
    Aug 9, 2004
Loading...

Share This Page