Create Table #A (id1 int,姓名 varchar(10),地址 varchar(10))
Create Table #B (id2 int,证件 varchar(10),分类 varchar(10))
INSERT INTO #A Values(1,'张三','测试')
INSERT INTO #A Values(1,'张三','测试')
INSERT INTO #A Values(2,'李四','测试')
--SELECT * FROM #A
INSERT INTO #B Values(1,'身份证','测试')
INSERT INTO #B Values(1,'身份证','测试')
INSERT INTO #B Values(2,'身份证','测试2')
--SELECT * FROM #B
SELECT id1,姓名,分类 FROM #A INNER JOIN #B ON #A.id1=#B.id2 GROUP BY id1,姓名,分类 Having Count(*)>=2
DROP TABLE #A
DROP TABLE #B