Solved

SQL to Find where NOT EXISTS

Posted on 2011-02-21
5
805 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 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

Courses: Start Training Online With Pros, Today

Brush up on the basics or master the advanced techniques required to earn essential industry certifications, with Courses. Enroll in a course and start learning today. Training topics range from Android App Dev to the Xen Virtualization Platform.

Question has a verified solution.

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

Suggested Solutions

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…
I originally created this report in Crystal Reports 2008 where there is an option to underlay sections. I initially came across the problem in Access Reports where I was unable to run my border lines down through the entire page as I was using the P…
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 …
With Secure Portal Encryption, the recipient is sent a link to their email address directing them to the email laundry delivery page. From there, the recipient will be required to enter a user name and password to enter the page. Once the recipient …

785 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