E
E
eldar_web2017-08-13 03:53:16
MySQL
eldar_web, 2017-08-13 03:53:16

How to find identical fields in one table in Ruby on Rails?

For example, there is an Address table with name fields.
There are two entries with the same title.
How to find two identical name-moves?
Address.where('name = name') doesn't work.

Answer the question

In order to leave comments, you need to log in

2 answer(s)
E
eldar_web, 2017-08-13
@eldar_web

Address.group(:name).having('count(*) > 1') и разбор.

D
Danil Sapegin, 2017-08-13
@ynblpb_spb

Why ask the same questions?
SELECT GROUP_CONCAT(id SEPARATOR ',') FROM Address GROUP BY name
There will be id fields separated by commas. It remains to split the line into commas and there will be line IDs

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question