• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 151
  • Last Modified:

Query question

hi,

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
thx
0
mcrmg
Asked:
mcrmg
  • 3
1 Solution
 
pteranodon72Commented:
SELECT * FROM Table1 WHERE Table1.ID Not In (SELECT ID FROM Table2);
0
 
mcrmgAuthor Commented:
thank you
0
 
mcrmgAuthor Commented:
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)
and
Table1.month(D1) Not In (SELECT month(D1) FROM Table2)


? it does not work...
0
 
mcrmgAuthor Commented:
I think I got it..thx
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Cloud Class® Course: SQL Server Core 2016

This course will introduce you to SQL Server Core 2016, as well as teach you about SSMS, data tools, installation, server configuration, using Management Studio, and writing and executing queries.

  • 3
Tackle projects and never again get stuck behind a technical roadblock.
Join Now