一个表中 几个字段构成一个唯一编码,如何查询记录的编码是唯一的呢

解决方案 »

  1.   

    group by 字段1,字段2,字段3,...
    having count(*)=1
      

  2.   

    select col1,col2...,count(*) from tb 
    group by 
    col1,col2..
    having count(*)>1
    --如果存在多count(*)>1,则不是唯一的了.
      

  3.   

    SELECT ... FROM TBL GROUP BY ... HAVING COUNT(1)=1
    count(1)=1可以确保唯一
      

  4.   

    where group by 字段1,字段2,字段3,...having count(1)=1