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
 General SQL Server Forums
 New to SQL Server Programming
 select from list only if not exist or before today

Author  Topic 

arielspecial
Starting Member

11 Posts

Posted - 2010-07-21 : 02:34:49
I select a bunch of records with id called recordID(unique), it works fine. Now I have another table with the recordID and nextUpdateDate.
I tried to select from the original list only those which are not in the second table at all or those which are there but their nextUpdateDate is before today. Can you help me?

arielspecial
Starting Member

11 Posts

Posted - 2010-07-21 : 02:46:26
sorry , I forgot to mention :
table 1: siteID (unique), subjectID(unique), title.. etc...
table 2: siteID, subjectID, nextUpdateDate
which means that in table 2 siteID can appear multiple times
but siteID+subjectID is unique.
So, from table1 I need to check for records in table 2 which for siteID+subjectID
are not in table2 or are there but he nextUpdateDate is before today.
Thanks
Go to Top of Page

arielspecial
Starting Member

11 Posts

Posted - 2010-07-22 : 06:16:05
well , found he answer:
and NOT EXISTS
(SELECT * FROM table2 where table1.siteID = table2.siteID
AND table2.subjectID=table1.subjectID AND table2.updateDate<getdate())
Go to Top of Page
   

- Advertisement -