Query question

Posted on 2008-10-15
Last Modified: 2012-05-05

I have two tables
Table1         Table2
ID   F1          ID      F1
1    aa          1       gg
2    bb          3       hh
3    cc          4       oo
4    dd          
5    ee          

My question is, how can I write a query that can display 2 and 5 from Table1
Question by:mcrmg
  • 3
LVL 14

Accepted Solution

pteranodon72 earned 80 total points
Comment Utility
SELECT * FROM Table1 WHERE Table1.ID Not In (SELECT ID FROM Table2);

Author Comment

Comment Utility
thank you

Author Comment

Comment Utility
sorry that the question is closed, if I need to add another condition to it

SELECT * FROM Table1 WHERE Table1.year(D1) Not In (SELECT year(D1) FROM Table2)
Table1.month(D1) Not In (SELECT month(D1) FROM Table2)

? it does not work...

Author Comment

Comment Utility
I think I got it..thx

Featured Post

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

'Between' is such a common word we rarely think about it but in SQL it has a very specific definition we should be aware of. While most database vendors will have their own unique phrases to describe it (see references at end) the concept in common …
Confronted with some SQL you don't know can be a daunting task. It can be even more daunting if that SQL carries some of the old secret codes used in the Ye Olde query syntax, such as: (+)     as used in Oracle;     *=     =*    as used in Sybase …
Access reports are powerful and flexible. Learn how to create a query and then a grouped report using the wizard. Modify the report design after the wizard is done to make it look better. There will be another video to explain how to put the final p…
In this tutorial you'll learn about bandwidth monitoring with flows and packet sniffing with our network monitoring solution PRTG Network Monitor ( If you're interested in additional methods for monitoring bandwidt…

762 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

10 Experts available now in Live!

Get 1:1 Help Now