I have mysql table called it as “R” which contains many fields, but I am worried about only one field that it “email”. Email contain email address it will contain duplicate entries. Now I wanna check for duplicate entries and count should increase by 1 for every unique email address and replicated emails should not be counted.
How do I implement this logic.
Kindly help me.
I am a newbie to ruby on rails world!!!
If you are just trying to count the number of unique email addresses for table my_table, and assuming you have set up an ActiveRecord model for it (which would be named MyTable), try:
That will run underlying SQL that looks like this:
That will return a number in both cases.