How to find all records that share the same field value as some other record?

Posted by Gj on Stack Overflow See other posts from Stack Overflow or by Gj
Published on 2010-06-13T01:40:03Z Indexed on 2010/06/13 1:42 UTC
Read the original article Hit count: 246

Filed under:
|
|

I need to extract all records which have a field which does NOT have a unique value.

I can't figure out an elegant way to do it - using annotation or some other way. I see a "value_annotate" method to the object manager but it's unclear if it's at all related.

Currently I'm using the inelegant way of simple looping through all values and doing a get on the value, and if there's an exception it means it's not unique..

Thanks

© Stack Overflow or respective owner

Related posts about sql

Related posts about django