Dear Alexander,
You may have a look on the "match2" function.
->
http://idlastro.gsfc.nasa.../pro/misc/match2.pro
With this function you can easily compare two vectors
match2, A, B, va, vb
test = where(va ne (-1), count)
if count eq n_elements(A) then C = 2
Cheers,
Vincent