如果比较表中同类型多列值是否相等?

KeyLife富翁笔记
作者: HongYuan
标题: 如果比较表中同类型多列值是否相等?
关键字: ttxxhhg
分类: 个人专区
密级: 公开
(评分: , 回复: 0, 阅读: 507) »»

原理:将多列合成一列,分组,如果比较一列 group by 行唯一标识 haing(*)=列数量
table1
a1 a2 a3 a4 a5 id
1  1   1  1 1   1
2  3   4  4 4   2
2  2   2  2 2   3
select * 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))


2005-9-23 16:45:54   
原文地址:https://www.cnblogs.com/ZhouXiHong/p/568232.html