I have a table with four columns, where col1 & col2 contain similar values (INT). I now want to know if there are duplicates in col1 and/or col2. i.e.,
col1 | col2
-----+-----
111 | 222
333 | 444
111 | 333
555 | 111
→ Duplicates: 111 (3x) and 333 (2x).
I am using SQLite, but I think this is a basic SQL question.
To get a count of each element use UNION ALL in a subquery, then GROUP BY on the result of that:
Add
HAVING COUNT(*) > 1if you only wish to see the duplicated values.