A
A
adam_carraway2020-02-06 15:20:53
Laravel
adam_carraway, 2020-02-06 15:20:53

How to get duplicates from a table?

The interests tab contains many identical entries:
id | user_id | name
1 | 1 | test
2 | 1 | test
3 | 1 | test
4 | 2 | test2
5 | 2 | test2
How to get id of duplicates using laravel?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
Alex Wells, 2020-02-06
@Alex_Wells

By user_id and name?
Pull user_id and name pairs

->select(['user_id', 'name'])
->groupBy(['user_id', 'name'])
->havingRaw('count(user_id) > 1')
->havingRaw('count(name) > 1')
->get()

then already on them, in a separate request, pull out the records themselves where'om.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question