原理:将多列合成一列,分组,如果比较一列 group by 行唯一标识 haing(*)=列数量table1a1 a2 a3 a4 a5 id1 1 1 1 1 12 3 4 4 4 22 2 2 2 2 3select * from table1 where id in(select id from (select id,a1 from table1 union select id,a2 from table group by id having count(*)=2))