Solved

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

Posted on 2002-06-28
7
335 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
ID: 7117127
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
ID: 7117282
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
ID: 7117300
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
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 
LVL 28

Expert Comment

by:AzraSound
ID: 7117325
add orders.orderstatus to your GROUP BY clause...
0
 
LVL 18

Author Comment

by:mgfranz
ID: 7117328
Thank you my friend!  :-)

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

Expert Comment

by:AzraSound
ID: 7117333
Glad I could help   :-)
0
 
LVL 18

Author Comment

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

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

I have helped a lot of people on EE with their coding sources and have enjoyed near about every minute of it. Sometimes it can get a little tedious but it is always a challenge and the one thing that I always say is:  The Exchange of information …
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…
Video by: Mark
This lesson goes over how to construct ordered and unordered lists and how to create hyperlinks.
Hi friends,  in this video  I'll show you how new windows 10 user can learn the using of windows 10. Thank you.

911 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

21 Experts available now in Live!

Get 1:1 Help Now