Results 1 to 6 of 6
  1. #1
    Join Date
    Jul 2003
    Posts
    1

    Angry Unanswered: Need Help Please!!!!!!!!!!

    I'm trying to run this script to pull a product listing based on the relationship i have created

    However i keep getting this error

    Syntax error (missing operator) in query expression

    I have no clue to what this means or how to fix it. Could someone please help. Thanks a head of time.

    Function getParentProdChildDetailSQL(rs)

    SQL = "SELECT tblProducts.prodID, tblProducts.prodName, tblProducts.prodImageSmallPath, tblProducts.prodDescription, tblProducts.prodLink, tblProducts.prodPrice, "_
    &" tblProducts.prodSaleIsActive, tblProducts.prodSalePrice, tblParentProdDetail.ProdID, tblParentProdDetail.ProdName, "_
    &" tblParentProdDetail.subParentProdProductId, tblSub_ParentProd.subParentProdProductId, tblParentProd.ParentprodID, "_
    &" tblSub_ParentProd.subParentProdID, tblParentProdDetail.subParentProdProductId "_
    '&" FROM tblSub_ParentProd INNER JOIN "_
    &" tblProducts INNER JOIN "_
    &" tblParentProdDetail ON tblProducts.prodID = tblParentProdDetail.ProdID ON "_
    &" tblSub_ParentProd.subParentProdID = tblParentProdDetail.subParentProdProductId INNER JOIN "_
    &" tblParentProd ON tblSub_ParentProd.subParentProdProductId = tblParentProd.ParentprodID "_'&" WHERE

    Do While Not rs.EOF
    SQL = SQL & " subParentProdProductId = " & rs.Fields("ParentProdID") & " OR "
    rs.MoveNext
    Loop

    SQL = Mid(SQL, 1, len(SQL)-3)
    getParentProdChildDetailSQL = SQL
    Else
    getParentProdChildDetailSQL = ""
    End If
    End Function

  2. #2
    Join Date
    Jul 2003
    Location
    PA
    Posts
    7
    I don't see any place where you're executing any SQL that would generate that error. Find the line where you're executing your SQL string (the error will tell you the line number), and instead of executing the SQL command, response.write it. Look at the SQL and see if you notice anything syntactically incorrect. If you're not sure, post it here and maybe someone will notice something.

  3. #3
    Join Date
    Jul 2003
    Location
    Ohio/Chicago
    Posts
    75
    take your string and paste it into the db command line directly. Replace your variables with constants and see where the error is then.

    Another cause is one or more form fields was empty. You should provide default values for all form fields that are used in the query.
    Last edited by unatratnag; 07-29-03 at 23:54.

  4. #4
    Join Date
    Jul 2003
    Location
    Ohio/Chicago
    Posts
    75
    ack, ray beat me to it. His way is also a most excellent way to see if one of your values is blank when you write it to screen.

  5. #5
    Join Date
    Aug 2003
    Location
    Kayseri-Turkiye
    Posts
    7
    Try to debug your code,

    Just comment .Execute(SQL) line, and place a:

    Repsonse.Write("<pre>" & SQL & "</pre>")

    Line inside your code where you can easily read it.

  6. #6
    Join Date
    Apr 2002
    Location
    Toronto, Canada
    Posts
    20,002
    it's right there, in plain sight

    you cannot say

    FROM x
    INNER JOIN y
    INNER JOIN z
    ON something
    ON something

    change this to

    FROM x
    INNER JOIN y
    ON something
    INNER JOIN z
    ON something


    rudy
    http://r937.com
    rudy.ca | @rudydotca
    Buy my SitePoint book: Simply SQL

Posting Permissions

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