从两列的 MySQL 表中查找相同的值


Find identical values from MySQL table from two columns

我只需要过滤这些在 x 和 y 列中具有相同值的表行。

 _______________________________________
|
|    x    |      y     |      name     |
________________________________________
|
|   1     |      2     |     A         |
|______________________________________
|   2     |      1     |      B        |
|______________________________________
|   1     |      2    |     C          | 
|_______________________________________  

最终结果应该是我有 A 和 C 结果。我需要过滤这些具有相同 x 和 y 值的行。

 _______________________________________
|
|    x    |      y     |      name     |
________________________________________
|
|   1     |      2     |     A         |
|______________________________________
 ______________________________________
|   1     |      2    |     C          | 
|_______________________________________  

我已经尝试过这段代码,但我只设法使用了一个字段。

select * 
from auto 
where x in (
        select x 
        from auto 
        group by x 
        having count(*) > 1
    );
SELECT t1.*
FROM tablename t1, tablename t2
WHERE t1.x = t2.x
AND t1.y = t2.y
AND t1.primary_key != t2.primary_key
select * from 
auto a, ( SELECT x, y, COUNT(*) FROM auto GROUP BY x, y HAVING COUNT(*) > 1 ) b
where a.x = b.x
and a.y = b.y

会将您的其他问题标记为重复