select distinct t_Emp.*,t_Contract.*,t_Department.FName 
from t_Emp,t_Contract,t_Department 
where t_Emp.FItemID=1001 
And t_Contract.FEmpID=1001 
and t_Department.FItemID=t_Emp.FDepID

解决方案 »

  1.   

    select distinct t_Emp.*,t_Contract.*,t_Department.FName --这里写想要的字段,重复的写一个就行了。
    from t_Emp,t_Contract,t_Department 
    where t_Emp.FItemID=1001 
    And t_Contract.FEmpID=1001 
    and t_Department.FItemID=(select t_Emp.FDepID from t_Emp where t_Emp.FItemID=1001)
      

  2.   

    本来如果是这样,是搜索得到数据的select distinct t_Emp.*,t_Contract.*
    from t_Emp,t_Contract,t_Department 
    where t_Emp.FItemID=1001 
    And t_Contract.FEmpID=1001 但是因为t_Emp.ID只是一个ID,没有说明内容,要知道内容,就要连接到t_Department.FItemID才可以看到,所以我才好像问题那样写的,但是那样写的话,就什么都搜索不出来了.
      

  3.   

    use 学生_课程
    select 学号,姓名
    from 学生
    where 所在系='MA'
    GO
      

  4.   

    select  t_Emp.*,t_Contract.*,t_Department.FName 
    from t_Emp,t_Contract,t_Department 
    where t_Emp.FItemID=1001 
    And t_Contract.FEmpID=1001 
    and t_Department.FItemID=t_Emp.FDepID--这句代替t_Department.FItemID=(select t_Emp.FDepID from t_Emp where t_Emp.FItemID=1001)
    --因为T_Emp表在上面出现过了