- Aug 28, 2001
- 52,844
- 1,049
- 126
simplified example:
select name, date
from table1
where date >= getdate() - 30 //all results in last 30 days
and name not in ('select distinct name from table2 where date >= getdate() - 45') //all results in last 45 days
(of course the above // remarks are not in my actual sql)
Have names and dates in both tables (not the same data but have coinciding names) and basically trying to get it to show all table1 names as long as they don't exist in table2 (in last 45 days). Why am I getting back all results in last 30 days regardless of the embedded select? I ran the embedded select on its own and it is working fine (more results) and it includes names I can see are in table1. So the check against each other is not working.
Is a join really necessary? Some syntax problem?
select name, date
from table1
where date >= getdate() - 30 //all results in last 30 days
and name not in ('select distinct name from table2 where date >= getdate() - 45') //all results in last 45 days
(of course the above // remarks are not in my actual sql)
Have names and dates in both tables (not the same data but have coinciding names) and basically trying to get it to show all table1 names as long as they don't exist in table2 (in last 45 days). Why am I getting back all results in last 30 days regardless of the embedded select? I ran the embedded select on its own and it is working fine (more results) and it includes names I can see are in table1. So the check against each other is not working.
Is a join really necessary? Some syntax problem?
