I recommend using Pick for these things. It has already been used by others but the simplest form using Alternatives hasn't been shown:
Pick[#, #[[All, 1]], Alternatives @@ #2] &[mymatrix, compvector] {{1, 1, -56}, {1, 2, 3.06}, {2, 0, -30.02}, {6, 1, 9.945}, {7, 0, -7.512}}
For greater speed especially with longer comvectors we can use a Dispatch table:
fast[m_, c_] := Pick[m, m[[All, 1]] /. Dispatch @ Thread[c -> True]] fast[mymatrix, compvector] {{1, 1, -56}, {1, 2, 3.06}, {2, 0, -30.02}, {6, 1, 9.945}, {7, 0, -7.512}}
Timings with some larger data:
mymatrix = RandomInteger[9999, {50000, 3}]; compvector = RandomChoice[Range@9999, 150]; (* the faster of Michael's functions *) michael[m_, c_] := With[{nf = Nearest[c]}, Pick[m, # - First /@ nf /@ # &@m[[All, 1]], 0] ] Cases[mymatrix, {x_, _, _} /; MemberQ[compvector, x]] // Timing // First Pick[#, #[[All, 1]], Alternatives @@ #2] &[mymatrix, compvector] // Timing // First michael[mymatrix, compvector] // Timing // First fast[mymatrix, compvector] // Timing // First 3.447
0.905
0.265
0.047
A run-off with Michael's method on even larger data:
mymatrix = RandomInteger[99999, {500000, 3}]; compvector = RandomChoice[Range@99999, 15000]; michael[mymatrix, compvector] // Timing // First fast[mymatrix, compvector] // Timing // First 15.943
0.327