有三个字段,ProductId,PNumber,PDate。当ProductId,PNumber值一样时,PDate值也必须一样,不允许出现不同的PDate。ProductId,PNumber相同值的记录有很多条,请问怎么处理呢?
1、假设你表中有一个唯一字段为ID
select a1.* from a as a1
inner join a as a2 on a1.id!=a2.id and a1.productId=a2.productid and a1.pnumber=a2.pnumber and a1.pdate=a2.pdate