I have a huge database called People with names and contact information. Then I have another one called Calls with every call to these people recorded. I have the the id from people and then the date of the call etc.
I need to do a query which will select all people that have never been called or that haven't been called in the last 90 days. There is no indication of calls in the poeple database.
This is what I have so far and it is obviously not good because it is just huge...
'need to get all people ID's
rs.Open "select people_id,people_name, country_id from people", getConnection(), adOpenStatic
'loop through all id's and see if there is a call for that person in the callstable
While Not rs.EOF
callRS.Open "select * from calls where people_id=" & rs("people_id"), getConnection(), adOpenStatic
'if rs is empty then add it to the list
If (callRS.BOF) And (callRS.RecordCount = 0) Then
'get the country
countryRS.Open "select nc from c where c= " & rs("country_id"), getConnection(), adOpenStatic
ListRes.AddItem (rs("people_id") & ";" & rs("people_name") & ";" & rs("country_id") & ";" & countryRS("nc"))
countryRS.Close
Set countryRS = Nothing
End If
callRS.Close
Set callRS= Nothing
rs.MoveNext
Wend
rs.Close
Set rs = Nothing
I need to do a query which will select all people that have never been called or that haven't been called in the last 90 days. There is no indication of calls in the poeple database.
This is what I have so far and it is obviously not good because it is just huge...
'need to get all people ID's
rs.Open "select people_id,people_name, country_id from people", getConnection(), adOpenStatic
'loop through all id's and see if there is a call for that person in the callstable
While Not rs.EOF
callRS.Open "select * from calls where people_id=" & rs("people_id"), getConnection(), adOpenStatic
'if rs is empty then add it to the list
If (callRS.BOF) And (callRS.RecordCount = 0) Then
'get the country
countryRS.Open "select nc from c where c= " & rs("country_id"), getConnection(), adOpenStatic
ListRes.AddItem (rs("people_id") & ";" & rs("people_name") & ";" & rs("country_id") & ";" & countryRS("nc"))
countryRS.Close
Set countryRS = Nothing
End If
callRS.Close
Set callRS= Nothing
rs.MoveNext
Wend
rs.Close
Set rs = Nothing