Answer the question
In order to leave comments, you need to log in
How to find duplicate records in a row by attribute?
Good afternoon,
There is such a table structure orders
id user_id product_id
1 1 2
2 2 2
3 2 3
4 2 4
5 1 2
6 1 5
7 1 5
8 1 5
Answer the question
In order to leave comments, you need to log in
Something like this ... unfortunately there is no way to check) But the meaning is this.
select * from your_table
INNER JOIN (
SELECT user_id, product_id
FROM your_table
GROUP BY user_id, product_id
HAVING COUNT(id) > 1
) as m ON m.user_id = your_table.user_id AND m.product_id = your_table.product_id
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question