Solved

SQL to Find where NOT EXISTS

Posted on 2011-02-21
5
802 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
5 Comments
 
LVL 40

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 119

Accepted Solution

by:
Rey Obrero 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

Maximize Your Threat Intelligence Reporting

Reporting is one of the most important and least talked about aspects of a world-class threat intelligence program. Here’s how to do it right.

Join & Write a Comment

In the previous article, Using a Critera Form to Filter Records (http://www.experts-exchange.com/A_6069.html), the form was basically a data container storing user input, which queries and other database objects could read. The form had to remain op…
Experts-Exchange is a great place to come for help with solutions for your database issues, and many problems are resolved within minutes of being posted.  Others take a little more time and effort and often providing a sample database is very helpf…
What’s inside an Access Desktop Database. Will look at the basic interface, Navigation Pane (Database Container), Tables, Queries, Forms, Report, Macro’s, and VBA code.
In Microsoft Access, when working with VBA, learn some techniques for writing readable and easily maintained code.

706 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

17 Experts available now in Live!

Get 1:1 Help Now