je to proveditelné, ale nejsem si jistý, jestli je to efektivnější než to dělat na úrovni aplikace:
váš stůl:
mysql> select * from test;
+----+--------+--------+--------+
| id | field1 | field2 | field3 |
+----+--------+--------+--------+
| 1 | A | B | C |
| 2 | D | E | F |
| 3 | A | H | I |
| 4 | J | K | A |
| 5 | M | D | O |
+----+--------+--------+--------+
5 rows in set (0.00 sec)
vyberte k nalezení podvodníků:
mysql> select count(value) as dupe_count,value from (select field1 as value from test union all select field2 from test union all select field3 from test) as tbl group by value having count(value) > 1 order by 1 desc;
+------------+-------+
| dupe_count | value |
+------------+-------+
| 3 | A |
| 2 | D |
+------------+-------+
2 rows in set (0.00 sec)
v podstatě sjednotíte tři sloupce do jednoho a poté hledáte podvodníky