Yes, the key is "key"...sorry for the pun.
The best way (that I know of) is to create 2 arrays--assuming
that the keys are numeric--and comparing the 2 arrays. That way,
it's only 2 SELECT queries to the DB and then CF processes
comparision.
For ex,
Query #1:
arrayfirst[1] = John
arrayfirst[2] = Mary
arrayfirst[3] = Larry
...where 1,2,3 are keys from 1st query
Query #2:
arraysecond[1] = Ken
arraysecond[2] = Mary
arraysecond[3] = Larry
...where 1,2,3 are keys from 2nd query
Then compare...