Solved

SQL to Find where NOT EXISTS

Posted on 2011-02-21
5
817 Views
Last Modified: 2012-05-11
Hi,

See attached - very simple database.
Table of Suppliers.
Table of products.
Table of prices of products for suppliers.

In theory, there should be a price in the prices table for every supplier/product combination.

I want a query that will show all Supplier/Product combinations that DO NOT exist in the tblPrices.


Database2.mdb
0
Comment
Question by:Patrick O'Dea
[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
5 Comments
 
LVL 41

Expert Comment

by:Sharath
ID: 34947176
Can you zip the attachment and upload it as I could not able to download the mdb extension files. If not, you can post some sample data with expected result. Otherwise, I hope someone will look into this.
0
 

Author Comment

by:Patrick O'Dea
ID: 34947207
Zipped as requested
Database2.zip
0
 
LVL 16

Assisted Solution

by:santoshmotwani
santoshmotwani earned 100 total points
ID: 34947251
select * from tblproduct , tblsupplier
where
supplierid = productid
and
supplierid not in ( select supplierid from tblprice )
and
productid not in ( select productid from tblprice)
0
 
LVL 120

Accepted Solution

by:
Rey Obrero (Capricorn1) earned 400 total points
ID: 34947257
try this

Select A.[ProductID],A.[SupplierID]
From
(
SELECT tblProduct.ProductID, tblSupplier.SupplierID
FROM tblProduct, tblSupplier
) A
Left Join tblPrice P On
A.[ProductID]=P.[ProductID] And A.[SupplierID]=P.[SupplierID]
Where P.[ProductID] is null And P.[SupplierID]  is null
0
 

Author Closing Comment

by:Patrick O'Dea
ID: 34947308
Thanks capricorn1 - Perfect!
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

A simple tool to export all objects of two Access files as text and compare it with Meld, a free diff tool.
This article describes two methods for creating a combo box that can be used to add new items to the row source -- one for simple lookup tables, and one for a more complex row source where the new item needs data for several fields.
In Microsoft Access, learn how to use Dlookup and other domain aggregate functions and one method of specifying a string value within a string. Specify the first argument, which is the expression to be returned: Specify the second argument, which …
In Microsoft Access, when working with VBA, learn some techniques for writing readable and easily maintained code.

691 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