mysql - How to find duplicate records in ActiveRecord other than original one -
using Rail 4, Ruby 2, MyScall
I would like to find all the records in my database which are Repeats the record - but not the original record.
That's because I can do update_attributes (: duplicate = & gt; true)
) on each of these records and can not be marked as the original duplicate.
You can say that I am looking at the opposite of Uniq
I do not want a universal value, I want all the values that are not unique after the fact. I do not want all prices to be duplicate, because it will include the original.
I do not like to use pure SQL or Ruby for this but I like to use an active record to keep it on track. Suppose that the table is called "lead" and we are looking for people where the area "telephone_number" is similar, I will leave record 1 alone and duplicate = true to 2,3 and 4 I can mark as
*
If I want to contrast the Unicode then
b = a.group_by {| H | H [: telephone_number]} .values.select {| A | | A.size & gt; 1}. Flaton
But all this record, I want to compare the other root with the original duplicate to this, besides this.
I believe your query that all the 'leads' get the same telephone number in an array. You can then use
b = b.shift
, which leave the first element of B array. You can then continue with your original idea, update_attributes (: duplicate => true)
Comments
Post a Comment