We investigate how to determine whether the states of a set of quantum systems are identical or not. This paper treats both error-free comparison, and comparison where errors in the result are allowed. Error-free comparison means that we aim to obtain definite answers, which are known to be correct, as often as possible. In general, we will also have to accept inconclusive results, giving no information. To obtain a definite answer that the states of the systems are not identical is always possible, whereas in the situation considered here, a definite answer that they are identical will not be possible. The optimal universal error-free comparison strategy is a projection onto the totally symmetric and the different non-symmetric subspaces, invariant under permutations and unitary transformations. We also show how to construct optimal comparison strategies when allowing for some errors in the result, minimizing either the error probability, or the average cost of making an error. We point out that it is possible to realize universal error-free comparison strategies using only linear elements and particle detectors, albeit with less than ideal efficiency. Also minimum-error and minimum-cost strategies may sometimes be realized in this way. This is of great significance for practical applications of quantum comparison.