我写了个两表联查语句
SELECT dbo.FieldValue.UId, dbo.FieldValue.FieldId, dbo.FieldValue.[Content], dbo.userPower.powerid
FROM dbo.FieldValue INNER JOIN dbo.userPower 
ON  dbo.FieldValue.FieldId = dbo.userPower.fieldid 
and dbo.userPower.powerid <> 1 
查出来很多重复数据,只想保存一条记录,不知道该怎么办,请各位指点下。谢谢!
我查询的结果显示为:
----------------------------------------------------------------------------
UId  FieldId  Content     powerid
3       1     wangjingru     2
3       1     wangjingru     2
3       2     WJR            3
3       2     WJR            3
3       3     [email protected]    3
3       3     [email protected]    3
怎样显示为:
----------------------------------------------------------------------------
UId  FieldId  Content     powerid
3       1     wangjingru     2
3       2     WJR            3
3       3     [email protected]    3各位请指点下,谢谢!

解决方案 »

  1.   

    SELECT distinct dbo.FieldValue.UId, dbo.FieldValue.FieldId, dbo.FieldValue.[Content], dbo.userPower.powerid
    FROM dbo.FieldValue INNER JOIN dbo.userPower  
    ON dbo.FieldValue.FieldId = dbo.userPower.fieldid  
    and dbo.userPower.powerid <> 1  
      

  2.   

    select distinct(UId+fieldid+........) from table
      

  3.   

    SELECT distinct dbo.FieldValue.UId, dbo.FieldValue.FieldId, dbo.FieldValue.[Content], dbo.userPower.powerid
    FROM dbo.FieldValue INNER JOIN dbo.userPower  
    ON dbo.FieldValue.FieldId = dbo.userPower.fieldid  
    and dbo.userPower.powerid <> 1