Wrox Programmer Forums
|
Access Discussion of Microsoft Access database design and programming. See also the forums for Access ASP and Access VBA.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Access 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 December 17th, 2007, 05:39 PM
Authorized User
 
Join Date: Dec 2007
Posts: 11
Thanks: 0
Thanked 0 Times in 0 Posts
Default Join Question

I have two tables orderHeader and orderDetails that have been imported from our ERP system. I have joined these on the orderNumber. orderHeader has the order number as the primary key. orderDetails is tied to orderHeader on the ordernumber field. There is a unique record in orderDetails for each order line item base on orderNumber. Therefore I have joined them on the order number. Pretty standard.:)

The problem is that not all orderHeader records have orderDetail records. For some reason, there are orders that were generated in our ERP system that do not have any line items. When I add additional fields to the query, I get errors (#Error - Invalid use of Null) in the result records.

How do I complete this query so that I only return orderHeader records that have at least 1 orderDeatil record? That would fix this issue.

Thanks.

 
Old December 18th, 2007, 10:38 AM
Friend of Wrox
 
Join Date: Mar 2004
Posts: 3,069
Thanks: 0
Thanked 10 Times in 10 Posts
Default

You seem to have a Left Join going on here where you are showing all records from OrderHeader whether they have an OrderDetails entry or not. You can change this Join to an Inner Join to remove the Null OrderDetails values, or in the criteria line of the query designer, just add "Is Not Null". This will suppress OrderHeader records that do not have OrderDetails entries.

Did that help?


mmcdonal

Look it up at: http://wrox.books24x7.com
 
Old December 18th, 2007, 10:40 AM
Friend of Wrox
 
Join Date: Mar 2004
Posts: 3,069
Thanks: 0
Thanked 10 Times in 10 Posts
Default

Sorry, add Is Not Null to the OrderDetails column.

mmcdonal

Look it up at: http://wrox.books24x7.com
 
Old December 18th, 2007, 12:43 PM
Authorized User
 
Join Date: Dec 2007
Posts: 11
Thanks: 0
Thanked 0 Times in 0 Posts
Default

I added "is not null" to the orderDetails OrderNumber criteria field, and it worked like a charm!

Thank you.






Similar Threads
Thread Thread Starter Forum Replies Last Post
Update inner join question Graham SQL Language 6 January 22nd, 2011 11:55 AM
Update and Inner Join Question - Access 97 snoopy92211 Access VBA 1 February 28th, 2005 04:30 PM
Oracle 8i inner join and left join problem puteri_84 Oracle 2 August 19th, 2004 07:14 AM
join erin SQL Language 4 October 27th, 2003 03:37 PM
easy join question jtyson SQL Server ASP 6 July 12th, 2003 08:41 AM





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