By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
438,660 Members | 1,593 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 438,660 IT Pros & Developers. It's quick & easy.

loop through records and disregard equal values

P: 1
hi everyone, i need some assistance.


i need to compare records from table A (database A) and records from table B (database B) and display list of this records. But i need to filter the list first and disregard agencies in table A that is already existing in table B. Anyway here's a draft of my code:

Expand|Select|Wrap|Line Numbers
  1. Set RS = SERVER.CreateObject("ADODB.Recordset")
  2. dts = "SELECT ID,officename,abbrev FROM lu_office ORDER BY ID"
  3. RS.open dts, cn_dts
  4. iddts = RS.getRows()
  5.  
  6. Set RS_map = SERVER.CreateObject("ADODB.Recordset")
  7. map = "SELECT * FROM map_agencies ORDER BY ID_dts"
  8. RS_map.open map,cn_yass
  9. dtsmap = RS_map.getRows()
  10.  
  11. For i = LBound(iddts,2) to UBound(iddts,2)
  12.     if iddts(0,i) <> dis then
  13.     For j = LBound(dtsmap,2) to UBound(dtsmap,2)
  14.         if iddts(0,i) <> dtsmap(1,j) then
  15.             Response.Write iddts(0,i) &" - "&dtsmap(1,j)&"<br>"
  16.         end if
  17.         if iddts(0,i) = dtsmap(1,j) then
  18.             dis = dtsmap(1,j)
  19.             Response.Write "DO NOT SHOW THIS: " & dtsmap(1,j) & "<br>"
  20.             exit For
  21.         end if
  22.     next
  23.     end if
  24. next
  25.  
its fine until for i loop for the third time coz the list again shows records existing in table B.

need help badly.
Thanks in advance!
Dec 16 '10 #1
Share this Question
Share on Google+
1 Reply


jhardman
Expert 2.5K+
P: 3,405
Look up the sql keyword "union", see if that answers your question (by default disregards duplicates in two different tables).

Jared
Dec 16 '10 #2

Post your reply

Sign in to post your reply or Sign up for a free account.