Mysql and ASP Query driving me nuts...

Results 1 to 2 of 2

Thread: Mysql and ASP Query driving me nuts...

  1. #1
    Join Date
    Dec 1969

    Default Mysql and ASP Query driving me nuts...

    I am trying to learn sql and Asp. Could anyone what is worng with the folowing statement?<BR>SELECT DISTINCTROW Order_Details.OrderID, Customers.CompanyName, Customers.ContactFirstName, Customers.ContactLastName, Customers.BillingAddress, Customers.City, Customers.StateOrProvince, Customers.PostalCode, Customers.Country, Customers.PhoneNumber, Customers.City, Customers.EmailAddress, Payments.CardType, Payments.CreditCardNumber, Payments.CreditCardExpDate, Payments.AuthCode, Payments.Approved, Orders.ShipContactFirstName, Orders.ShipContactLastName, Orders.ShipName, Orders.ShipAddress, Orders.ShipCity, Orders.ShipStateOrProvince, Orders.ShipPostalCode, Orders.ShipCountry, Orders.ShipPhoneNumber, Orders.FreightCharge, Order_Details.ProductID, Order_Details.Quantity, Order_Details.UnitPrice, Products.ProductName FROM (Products INNER JOIN ((Customers INNER JOIN Orders ON Customers.CustomerID = Orders.CustomerID) INNER JOIN Order_Details ON Orders.OrderID = Order_Details.OrderID) ON Products.ProductID = Order_Details.ProductID) INNER JOIN Payments ON Orders.OrderID = Payments.OrderID ORDER BY Order_Details.OrderID DESC;<BR><BR>Here&#039;s the error I get:<BR><BR>Error Type:<BR>Microsoft OLE DB Provider for ODBC Drivers (0x80040E09)<BR>[TCX][MyODBC]You have an error in your SQL syntax near &#039;((Customers INNER JOIN Orders ON Customers.CustomerID = Orders.CustomerID) INNER&#039; at line 1<BR><BR>Thanks,<BR><BR>Roberto

  2. #2
    Join Date
    Dec 1969

    Default Since all you have...

    ...are simple inner joins, you might try "implicit" joins instead of explicit ones.<BR><BR>That is you do:<BR><BR>SELECT DISTINCTROW Order_Details.OrderID, ... , Products.ProductName <BR>FROM Products, Customers, Orders, Order_Details, Payments<BR>WHERE Customers.CustomerID = Orders.CustomerID<BR>AND Orders.OrderID = Order_Details.OrderID<BR>AND Products.ProductID = Order_Details.ProductID<BR>AND Orders.OrderID = Payments.OrderID <BR>ORDER BY Order_Details.OrderID DESC;<BR><BR>That really *does* do the same thing and it avoids the complicated syntax of nested explicit inner joins. <BR><BR>

Posting Permissions

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