Solved

Query to EXCLUDE items?

Posted on 2008-06-10
2
1,320 Views
Last Modified: 2012-06-21
Hi Experts,

I have 1 query that extracts e-mail addresses from clients that have made a booking, in order to e-mail them for their feedback:
SELECT First(Clients.Lead_Name) AS FirstOfLead_Name, First(Clients.First_Name) AS FirstOfFirst_Name, First(Clients.Title) AS FirstOfTitle, Clients.[E-Mail], Clients.Client_ID
FROM bookings INNER JOIN Clients ON bookings.Client_ID = Clients.Client_ID
GROUP BY Clients.[E-Mail], Clients.Client_ID
HAVING ((Not (Clients.[E-Mail]) Is Null));

I have another query that extracts e-mail addresses from clients that have requested quotations so that a follow up can be sent:
SELECT First(Clients.Lead_Name) AS FirstOfLead_Name, First(Clients.First_Name) AS FirstOfFirst_Name, First(Clients.Title) AS FirstOfTitle, Clients.[E-Mail], Clients.Client_ID
FROM Clients INNER JOIN quotations ON Clients.Client_ID = quotations.Client_ID
GROUP BY Clients.[E-Mail], quotations.Booking_ID, Clients.Client_ID
HAVING ((Not (Clients.[E-Mail]) Is Null) AND ((quotations.Booking_ID)=0));

My problem is that I don't want to send a quotation follow up to anyone that has booked. I understand how I could extract that data by creating a new query of client id's that appear in both of the above queries ie: if there's a matching client_id, then they are in both the booking and quotation list.

My question: is it possible to modify the quotations list query to exclude the matching entries using a query? I know that I could do this in a module by ignoring the matching entries but it would fit much better into the existing system if I could filter the data beforehand.
0
Comment
Question by:redpoppy
[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 Comments
 
LVL 22

Accepted Solution

by:
Kelvin Sparks earned 500 total points
ID: 21749795
Something like
SELECT First(Clients.Lead_Name) AS FirstOfLead_Name, First(Clients.First_Name) AS FirstOfFirst_Name, First(Clients.Title) AS FirstOfTitle, Clients.[E-Mail], Clients.Client_ID
FROM Clients INNER JOIN quotations ON Clients.Client_ID = quotations.Client_ID
GROUP BY Clients.[E-Mail], quotations.Booking_ID, Clients.Client_ID
HAVING ((Not (Clients.[E-Mail]) Is Null) AND ((quotations.Booking_ID)=0) AND Clients.Client_ID NOT IN(SELECT Client_ID FROM bookings INNER JOIN Clients ON bookings.Client_ID = Clients.Client_ID));

Kelvin
0
 

Author Closing Comment

by:redpoppy
ID: 31465671
Hi Kelvin - that's fantastic, worked a treat, first time! Thanks a lot
0

Featured Post

Salesforce Made Easy to Use

On-screen guidance at the moment of need enables you & your employees to focus on the core, you can now boost your adoption rates swiftly and simply with one easy tool.

Question has a verified solution.

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

Did you know that more than 4 billion data records have been recorded as lost or stolen since 2013? It was a staggering number brought to our attention during last week’s ManageEngine webinar, where attendees received a comprehensive look at the ma…
Traditionally, the method to display pictures in Access forms and reports is to first download them from URLs to a folder, record the path in a table and then let the form or report pull the pictures from that folder. But why not let Windows retr…
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…
Familiarize people with the process of retrieving data from SQL Server using an Access pass-thru query. Microsoft Access is a very powerful client/server development tool. One of the ways that you can retrieve data from a SQL Server is by using a pa…

630 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