SQL 查询不重复记录select * from [Nop_ProductVariantAttributeValue]where [Name] in (select [Name] fr
SQL 查询不重复记录
select * from [Nop_ProductVariantAttributeValue] where [Name] in (select [Name] from [Nop_ProductVariantAttributeValue] group by [Name] having(count(*))=1)
--用主键去过滤 select * from [Nop_ProductVariantAttributeValue] a where not exists (select 1 from [Nop_ProductVariantAttributeValue] where a.name=name and 主键<a.主键)--如果多主键 就主键1+主键2<a.主键1+a.主键2
[解决办法] select a.* from [Nop_ProductVariantAttributeValue] a inner join (select name,min(id) id from [Nop_ProductVariantAttributeValue] group by name) b on a.id=b.id