Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9276417
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 18, 20262026-06-18T16:50:54+00:00 2026-06-18T16:50:54+00:00

I am using Microsoft Access 2007 and found that this SQL does not have

  • 0

I am using Microsoft Access 2007 and found that this SQL does not have the EXCEPT operator. I learned that I can use LEFT JOIN and IS NULL to perform this operation. I almost have it but can’t quite put my thumb on it.

I have two tables, Table A has data of a personID, foodID, and timePURCHASED. A person with an ID buys food of ID at a certain time. Table B is a subset of that. (It has selected rows from Table A.)

My goal is to do: Table A EXCEPT Table B.

Table A

personIDfoodIDtimePURCHASED             
1            1         2/6/2012 1:00:00 PM       

1            4         2/6/2012 6:00:00 PM       

2            3         2/7/2012 8:00:00 PM       

3            1         2/6/2012 9:00:00 PM       

3            3         2/6/2012 4:00:00 PM       

Table B

personIDfoodIDtimePURCHASED             
1            1         2/6/2012 1:00:00 PM       

3            3         2/6/2012 4:00:00 PM       

GOAL

personIDfoodIDtimePURCHASED             

1            4         2/6/2012 6:00:00 PM       

2            3         2/7/2012 8:00:00 PM       

3            1         2/6/2012 9:00:00 PM       

Here is my code I started:

SELECT A.personID, A.foodID, A.timePURCHASED  
FROM A  
LEFT JOIN B ON (A.personID = B.personID)   
WHERE ((B.personID) Is Null);

I understand that this will result in my GOAL table not having any matching personID (1, 3) and leave behind personID not matched (2). I understand that I need to consider all three columns at the same time and found that I can use the AND operator in my LEFT JOIN:

SELECT A.personID, A.foodID, A.timePURCHASED  
FROM A  
LEFT JOIN B ON (A.personID = B.personID)  
AND (A.foodID = B.foodID)  
AND (A.timePURCHASED = B.timePURCHASED)  
WHERE (((B.personID) Is Null)  
AND ((B.foodID) Is Null)  
AND ((B.timePURCHASED) Is Null));

So far this has not worked and I am looking for some advice. I apologize for the format, TLDR, or if this is something easier to answer. I am a novice and learning SQL. Thank you for any assistance.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-18T16:50:55+00:00Added an answer on June 18, 2026 at 4:50 pm

    Your second query generally looks good. You don’t need all 3 IS NULL checks, though, since you don’t have any nulls in your input set. You can also get rid of all those parentheses.

    SELECT A.personID, A.foodID, A.timePurchased 
      FROM A 
      LEFT JOIN B 
      ON A.personID = B.personID
        AND A.foodID = B.foodID
        AND A.timePurchased = B.timePurchased
      WHERE B.personID is null;
    

    This works perfectly (meaning it outputs exactly the “GOAL” relation you specify) on a brand-new database I set up from your specifications, but so does your second query.

    So it seems like something must be wrong with the setup, not with the SQL itself. What does your CREATE TABLE statement look like for these two tables? Specifically, what are the data types that you are comparing? Are the timePURCHASED columns strings under the hood? If so, do they have spaces in them? Does one table have strings and the other DATETIMEs? And to Terje D.’s point, what precisely is the result you’re seeing?

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have wrote a code that can read an excel 2007 file using Microsoft
i am using microsoft access jet sql. i have table col1 and col2 i
So I wrote a project-management program for a small business using Microsoft Access 2007.
I am using Microsoft Access database for storing data. In that, I stored date
I have just started using the Data Access Application Block from microsoft. There are
using Microsoft.SqlServer.Management.SqlStudio.Explorer; unable to find this pls assist [update] found the dll's in this
I'm using the data collection features available through Microsoft Access 2007 and Microsoft Outlook
I'm new creating applications using Visual Studio 2010 and Microsoft Access 2007. I already
I am new in creating application using Visual Studio 2010 and Microsoft Access 2007.
I'm using microsoft Access. If this query: (SELECT FERMENT.FermentId FROM FERMENT INNER JOIN [BELGIUM

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.