Solved

INNER JOIN (Table INNER JOIN [table] ON...)

Posted on 2002-06-28
7
333 Views
Last Modified: 2008-02-20
I'm stuck... why won't this join work?

tallySql = "select orderitems.ProductId, tblProduct.ItemName, orders.orderstatus, sum(orderItems.Qty) as sumQty from OrderItems INNER JOIN (orders INNER JOIN [tblProduct] ON orderItems.ProductId=tblProduct.ItemSKU) ON orders.orderid=orderitems.orderid WHERE orders.orderstatus = 'a' group by orderItems.ProductId, tblProduct.ItemName order by orderItems.ProductId"
0
Comment
Question by:mgfranz
  • 3
  • 3
7 Comments
 
LVL 28

Accepted Solution

by:
AzraSound earned 50 total points
Comment Utility
You are joining the [Orders] table and the [tblproduct] table based on criteria that uses the [orderItems] table.  Maybe it should look like this:


tallySql = "select orderitems.ProductId, tblProduct.ItemName, orders.orderstatus, sum(orderItems.Qty) as sumQty from (tblProduct INNER JOIN (orders INNER JOIN OrderItems ON orders.orderid=orderitems.orderid) ON orderItems.ProductId=tblProduct.ItemSKU) WHERE orders.orderstatus = 'a' group by orderItems.ProductId, tblProduct.ItemName order by orderItems.ProductId"
0
 
LVL 2

Expert Comment

by:prokni
Comment Utility
What about this?
select
     orderitems.ProductId, tblProduct.ItemName, orders.orderstatus,      sum(orderItems.Qty) as sumQty
from
     OrderItems,orders,[tblProduct]
WHERE
     orderItems.ProductId=tblProduct.ItemSKU and
     orders.orderid=orderitems.orderid  and
     orders.orderstatus = 'a'
group by
     orderItems.ProductId, tblProduct.ItemName
order by
     orderItems.ProductId"
0
 
LVL 18

Author Comment

by:mgfranz
Comment Utility
I get this error with either query;

Category=Microsoft JET Database Engine
Number=(0x80040E21)
Description=You tried to execute a query that does not include the specified expression 'orderstatus' as part of an aggregate function.
0
Highfive Gives IT Their Time Back

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

 
LVL 28

Expert Comment

by:AzraSound
Comment Utility
add orders.orderstatus to your GROUP BY clause...
0
 
LVL 18

Author Comment

by:mgfranz
Comment Utility
Thank you my friend!  :-)

[I don't think I'll ever get the hang of full queries...]
0
 
LVL 28

Expert Comment

by:AzraSound
Comment Utility
Glad I could help   :-)
0
 
LVL 18

Author Comment

by:mgfranz
Comment Utility
I can always rely on some other smart mind to save me...
0

Featured Post

IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

I was asked about the differences between classic ASP and ASP.NET, so let me put them down here, for reference: Let's make the introductions... Classic ASP was launched by Microsoft in 1998 and dynamically generate web pages upon user interact…
This demonstration started out as a follow up to some recently posted questions on the subject of logging in: http://www.experts-exchange.com/Programming/Languages/Scripting/JavaScript/Q_28634665.html and http://www.experts-exchange.com/Programming/…
Internet Business Fax to Email Made Easy - With eFax Corporate (http://www.enterprise.efax.com), you'll receive a dedicated online fax number, which is used the same way as a typical analog fax number. You'll receive secure faxes in your email, fr…
In this tutorial you'll learn about bandwidth monitoring with flows and packet sniffing with our network monitoring solution PRTG Network Monitor (https://www.paessler.com/prtg). If you're interested in additional methods for monitoring bandwidt…

771 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

10 Experts available now in Live!

Get 1:1 Help Now