SQL Server Forums
Profile | Register | Active Topics | Members | Search | Forum FAQ
 
Register Now and get your question answered!
Username:
Password:
Save Password
Forgot your Password?

 All Forums
 SQL Server 2008 Forums
 Transact-SQL (2008)
 select
 New Topic  Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic  

arkiboys
Flowing Fount of Yak Knowledge

1417 Posts

Posted - 04/22/2013 :  08:55:32  Show Profile  Reply with Quote
Hello,
I am trying to have a query so that the data in tbl2 is not the same as the ones in tblMain. The two fields I am looking are field2 and field3
Is my query correct? thanks

select field1, ID, date, field4
from tbl2
where
ID not in (select field3 from tblMain)
and date not in (select date from tblMain)

James K
Flowing Fount of Yak Knowledge

3662 Posts

Posted - 04/22/2013 :  08:59:51  Show Profile  Reply with Quote
If you are looking for the combination of field3 and date (rather than one or the other), the syntax should be like this:
select field1, ID, date, field4
from tbl2 t
where
not exists 
( select * from tblMain m where m.field3 = t.ID and m.date = t.date)
Go to Top of Page

arkiboys
Flowing Fount of Yak Knowledge

1417 Posts

Posted - 04/22/2013 :  09:27:42  Show Profile  Reply with Quote
thanks
Go to Top of Page
  Previous Topic Topic Next Topic  
 New Topic  Reply to Topic
 Printer Friendly
Jump To:
SQL Server Forums © 2000-2009 SQLTeam Publishing, LLC Go To Top Of Page
This page was generated in 0.03 seconds. Powered By: Snitz Forums 2000