SELECT distinct * from table
查询后面加上distinct 去除重复数据

解决方案 »

  1.   

    已经有distinct了 语句的第一行就有distinct 
      

  2.   


    select distinct  
    [tEmployee].[EmpName]as'User',[tEmployee].[EmpPassword],  
    [tDepartment].[DeptId],[tDepartment].[DeptName],[tDepartment].[DeptNO],
    [tCompanyEmployee].[EmpName],[tCompanyEmployee].[EmpNO],[tCompanyEmployee].[Sex]
    from [tEmployee]
    inner join [tDepartment] on [tEmployee].[DeptID]=[tDepartment].[DeptID]  inner join [tCompanyEmployee] on [tEmployee].[DeptID]=[tCompanyEmployee].[DeptID]
      

  3.   

    select distinct   * from(select 
    [tEmployee].[EmpName]as'User',[tEmployee].[EmpPassword],  
    [tDepartment].[DeptId],[tDepartment].[DeptName],[tDepartment].[DeptNO],
    [tCompanyEmployee].[EmpName],[tCompanyEmployee].[EmpNO],[tCompanyEmployee].[Sex]
    from [tEmployee]
    inner join [tDepartment] on [tEmployee].[DeptID]=[tDepartment].[DeptID]  inner join [tCompanyEmployee] on [tEmployee].[DeptID]=[tCompanyEmployee].[DeptID]
    )
      

  4.   

    ok搞定
    条件不够 所以无法去掉重复 
    tDepartment字段:
    [DeptID] [DeptNO] [DeptName]
    tCompanyEmployee字段:
    [cEmpID] [DeptID] [EmpNO] [EmpName] [Sex]
    tEmployee字段:
    [EmpID] [cEmpID] [DeptID] [EmpName] [EmpPassword]
    第二个表和第三个表里面有多个字段相同
    就在inner join 'table' on后面再加一个条件
    语句:
    create view v_tDep_tCom
    as
    select
    [tDepartment].[DeptId],[tDepartment].[DeptName],[tDepartment].[DeptNO],
    [tCompanyEmployee].[cEmpID],[tCompanyEmployee].[EmpName],[tCompanyEmployee].[EmpNO],[tCompanyEmployee].[Sex]
    from [tDepartment] 
    inner join [tCompanyEmployee] 
    on [tDepartment].[DeptID]=[tCompanyEmployee].[DeptID] 
    GOselect * 
    from [v_tDep_tCom]
    inner join [tEmployee]
    on [v_tDep_tCom].[DeptID]=[tEmployee].[DeptId] and [v_tDep_tCom].[cEmpID]=[tEmployee].[cEmpID]
      

  5.   

    看起来还真有点费劲。这几天我也遇到了inner join后出现重复数据的问题。