Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2008 Forums
 Transact-SQL (2008)
 select

Author  Topic 

arkiboys
Master Smack Fu Yak Hacker

1433 Posts

Posted - 2013-04-22 : 08:55:32
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
Master Smack Fu Yak Hacker

3873 Posts

Posted - 2013-04-22 : 08:59:51
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
Master Smack Fu Yak Hacker

1433 Posts

Posted - 2013-04-22 : 09:27:42
thanks
Go to Top of Page
   

- Advertisement -