Solved

correlation subquery.

Posted on 1998-09-28
3
411 Views
Last Modified: 2011-10-03
I have two tables of data: Jobs and Invoices. Essentially, invoices is a subset of jobs. How can I create a query which will list the jobs that do *not* have a corresponding invoice?  
0
Comment
Question by:zzchoffm
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
3 Comments
 
LVL 5

Accepted Solution

by:
chewhoung earned 100 total points
ID: 1963742
Try this:
select * from Jobs where Jobs.JobId not in (select JobiD from Invoice)

0
 

Expert Comment

by:dtburdick
ID: 14652633
For anyone reading this thread, this is a very slow way of doing it.  You are better off doing an outer join and then adding to the clause where the Second ID Is Null.  I increased a 10 minute query to 2 seconds doing this once.

Ie.

SELECT Jobs.*
FROM Jobs LEFT JOIN Invoices ON Jobs.JobID = Invoices.JobID
WHERE (((Invoices.InvoiceID) Is Null));

or in old style SQL

SELECT Jobs.*
FROM Jobs, Invoices
WHERE Jobs.JobID *= Invoices.JobID
AND Invoices.InvoiceID Is Null
0
 

Expert Comment

by:dtburdick
ID: 14652640
Um, duh.  I mean I DECREASED the query time, not increased. :)
0

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Overview: This article:       (a) explains one principle method to cross-reference invoice items in Quickbooks®       (b) explores the reasons one might need to cross-reference invoice items       (c) provides a sample process for creating a M…
In Part II of this series, I will discuss how to identify all open instances of Excel and enumerate the workbooks, spreadsheets, and named ranges within each of those instances.
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…
Learn how to number pages in an Access report over each group. Activate two pass printing by referencing the pages property: Add code to the Page Footers OnFormat event to capture the pages as there occur for each group. Use the pages property to …

730 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