查询数据当列1重复,列2 不重复的数据
有这样一个表数据:列:1,2,3;ID,Name,Num
12ALUMINUM HYDROXIDE;CI 77891;MICA;SILICA;SODIUM MYRISTOYL GLUTAMATE 0.5;58.865;27.985;9.65;3
13ALUMINUM HYDROXIDE;CI 77891;MICA;SILICA;SODIUM MYRISTOYL GLUTAMATE 0.5;52.11;34.74;9.65;3
14PHENOXYETHANOL 100
15ALGAE EXTRACT;AQUA;GLYCERIN 2;48;50
16CAPRYLYL GLYCOL 100
17BETULA ALBA JUICE;BIOTIN;CITRIC ACID;GLYCERIN;PHENOXYETHANOL;POTASSIUM SORBATE;SODIUM CITRATE 83.248;0.002;0.07;15;1.3;0.13;0.25
18AQUA;PHENOXYETHANOL;SODIUM DNA 99.59;0.4;0.01
19AQUA;PHENOXYETHANOL;SODIUM DNA 99.59;0.4;0.01
select * from tb t where exists(select 1 from tb where Name=t.Name and Num<>t.Num)
select * from tb t1
where
exists(select 1 from tb where [name]=t1.[name] and id<t1.id) --列1重复 若列1为[name]的话
and not exists(select 1 from tb where num=t1.num and id<t1.id) --列2 num不重复