Finding route number

  • Thread starter Thread starter Nick
  • Start date Start date
N

Nick

I have two table, Table1 has the primary key (route) and
table2 (history)is the child where a log is created on
certain data entries on the route. I want to find the
route where the route or routes have not had any history
entries in the last x days. I can create a query that
will tell me which have had entries but not the other
way.
 
I have two table, Table1 has the primary key (route) and
table2 (history)is the child where a log is created on
certain data entries on the route. I want to find the
route where the route or routes have not had any history
entries in the last x days. I can create a query that
will tell me which have had entries but not the other
way.

Try a NOT EXISTS criterion (note that the optimizer doesn't handle
these well so it may be sssslllloooowwww...)

SELECT Table1.*
WHERE NOT EXISTS
(SELECT Route FROM Table2 WHERE Table1.Route = Table2.Route
AND Table2.Datefield > DateAdd("d", -14, Date()))
 
-----Original Message-----


Try a NOT EXISTS criterion (note that the optimizer doesn't handle
these well so it may be sssslllloooowwww...)

SELECT Table1.*
WHERE NOT EXISTS
(SELECT Route FROM Table2 WHERE Table1.Route = Table2.Route
AND Table2.Datefield > DateAdd("d", -14, Date()))



.
Thanks I will try it..
 
-----Original Message-----


Try a NOT EXISTS criterion (note that the optimizer doesn't handle
these well so it may be sssslllloooowwww...)

SELECT Table1.*
WHERE NOT EXISTS
(SELECT Route FROM Table2 WHERE Table1.Route = Table2.Route
AND Table2.Datefield > DateAdd("d", -14, Date()))



.
I can not get the "Where Not Exists" to work.
The "Where" shows me the the data where there is a log
listing. What have I missed?
 
I can not get the "Where Not Exists" to work.
The "Where" shows me the the data where there is a log
listing. What have I missed?

Please post the actual SQL of your query, and perhaps an example of
what you're seeing that you don't want (or not seeing that you do).
 
Back
Top