Wrox Programmer Forums
|
Classic ASP Databases Discuss using ASP 3 to work with data in databases, including ASP Database Setup issues from the old P2P forum on this specific subtopic. See also the book forum Beginning ASP.NET Databases for questions specific to that book. NOT for ASP.NET 1.0, 1.1, or 2.0.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Classic ASP Databases section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old July 8th, 2003, 03:39 PM
Authorized User
 
Join Date: Jun 2003
Posts: 24
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via AIM to tp194
Default SQL Inner Join Problem

So, I would first like to thank everyone for always being able to push me in the right direction, whenever I'm stuck...that being said, I do have a problem.

I have a web page where a user can select a commodity code, and based on the selection a buyer's contact info should popup.

The db contains three tables 1) buyerTable, 2) linkToBuyerTable, 3) commodityCodeList.

The error message that I get is:

Microsoft JET Database Engine (0x80040E14)
Syntax error in JOIN operation.
/buyerListing/resultsPage.asp, line 76

Any help is much appreciated...

Terry


<%
    Dim commodity, staff

    commodity = Request.Form("commodity")
    staff = Request.Form("staff")

%>

<%
    Dim objCommand, objCommand2, selectedGroup, objRS

    Set objCommand = Server.CreateObject("ADODB.Command")

    objCommand.ActiveConnection = strConnect

    objCommand.CommandText = "SELECT buyerTable.buyerName, buyerTable.phone, buyerTable.email, buyerTable.title " & _
        "FROM buyerTable INNER JOIN " & _
        "(linkToBuyerTable INNER JOIN " & _
        "commodityCodeList " & _
        "ON (linkToBuyerTable.categoryId = commodityCodeList.categoryId)) " & _
        "ON (buyerTable.buyerInitials = linkToCategory.buyerInitials) " & _
        "WHERE commodityCodeList.categoryId = commodity"

    objCommand.CommandType = adCmdText

    objCommand.Parameters("commodity") = commodity

    Set objRS = objCommand.Execute

    While Not objRS.EOF

        Response.Write objRS("buyerName") & "<br>"
        Response.Write objRS("title") & "<br>"
        Response.Write objRS("phone") & "<br>"
        Response.Write objRS("<a href='mailto:'email'>'email'") & "<br>"

        objRS.MoveNext
    Wend
 
Old July 8th, 2003, 09:45 PM
Authorized User
 
Join Date: Jun 2003
Posts: 16
Thanks: 0
Thanked 0 Times in 0 Posts
Default

>ON (buyerTable.buyerInitials = linkToCategory.buyerInitials)
you specify linkToCategory instead of linkToBuyerTable

>WHERE commodityCodeList.categoryId = commodity
>objCommand.Parameters("commodity") = commodity
you cannot add parameter that way

if you want to use parameter, try (assume commodity is an integer):

"SELECT buyerTable.buyerName, buyerTable.phone, " & _
"buyerTable.email, buyerTable.title FROM buyerTable " & _
"INNER JOIN linkToBuyerTable ON " & _
"buyerTable.buyerInitials = linkToBuyerTable.buyerInitials " & _
"INNER JOIN commodityCodeList ON "
"ON linkToBuyerTable.categoryId = commodityCodeList.categoryId " & _
"WHERE commodityCodeList.categoryId = ?"

objCommand.Parameters.Append objCommand.CreateParameter("commodity", adInteger, , , commodity)"


or without append any paramter to Command object:

"SELECT buyerTable.buyerName, buyerTable.phone, " & _
"buyerTable.email, buyerTable.title FROM buyerTable " & _
"INNER JOIN linkToBuyerTable ON " & _
"buyerTable.buyerInitials = linkToBuyerTable.buyerInitials " & _
"INNER JOIN commodityCodeList ON "
"ON linkToBuyerTable.categoryId = commodityCodeList.categoryId " & _
"WHERE commodityCodeList.categoryId = " & commodity

Regards,
Khoa Nguyen
 
Old July 8th, 2003, 09:59 PM
Authorized User
 
Join Date: Jun 2003
Posts: 24
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via AIM to tp194
Default

Thanks Khoa...it was a stupid typo.

t~





Similar Threads
Thread Thread Starter Forum Replies Last Post
SQL INNER JOIN problem lawsoncobol Access VBA 1 August 17th, 2006 02:29 PM
My SQL, ASP, and Inner Join Knuckles2003 Classic ASP Databases 0 October 31st, 2005 02:24 AM
SQL join problem mattastic SQL Language 2 May 26th, 2005 08:27 AM
SQL Join mattastic SQL Server 2000 9 April 21st, 2005 10:27 AM
Oracle 8i inner join and left join problem puteri_84 Oracle 2 August 19th, 2004 07:14 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.