loop through records and disregard equal values

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Drei Divina
    New Member
    • Dec 2010
    • 1

    #1

    loop through records and disregard equal values

    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:

    Code:
    Set RS = SERVER.CreateObject("ADODB.Recordset")
    dts = "SELECT ID,officename,abbrev FROM lu_office ORDER BY ID"
    RS.open dts, cn_dts
    iddts = RS.getRows()
    
    Set RS_map = SERVER.CreateObject("ADODB.Recordset")
    map = "SELECT * FROM map_agencies ORDER BY ID_dts"
    RS_map.open map,cn_yass
    dtsmap = RS_map.getRows()
    
    For i = LBound(iddts,2) to UBound(iddts,2)
    	if iddts(0,i) <> dis then
    	For j = LBound(dtsmap,2) to UBound(dtsmap,2)
    		if iddts(0,i) <> dtsmap(1,j) then
    			Response.Write iddts(0,i) &" - "&dtsmap(1,j)&"<br>"
    		end if
    		if iddts(0,i) = dtsmap(1,j) then
    			dis = dtsmap(1,j)
    			Response.Write "DO NOT SHOW THIS: " & dtsmap(1,j) & "<br>"
    			exit For
    		end if
    	next
    	end if
    next
    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!
  • jhardman
    Recognized Expert Specialist
    • Jan 2007
    • 3405

    #2
    Look up the sql keyword "union", see if that answers your question (by default disregards duplicates in two different tables).

    Jared

    Comment

    Working...