有一员工资料表 R_YG
查找与胡明在同一个单位的员工姓名、性别、部门和职称
       select 单位,姓名,性别,部门,职称 from R_YC as a
where 单位=
           (select 姓名,性别,部门,职称 from R_YC where 单位=a.单位,姓名=胡明)
    这样写对吗?不对麻烦帮忙修改正确,谢谢

解决方案 »

  1.   


    select 单位,姓名,性别,部门,职称 from R_YC as a
    where 单位 in
    (select 单位  from R_YC where 姓名=胡明)
      

  2.   

    select 单位,姓名,性别,部门,职称 from R_YC as a
    where 单位=
    (select 单位 from R_YC where 姓名=胡明)
      

  3.   


    select 单位,姓名,性别,部门,职称 from R_YC as a
    where 单位 in
    (select 单位  from R_YC where 姓名='胡明')
      

  4.   

    select
     单位,姓名,性别,部门,职称 
    from
     R_YC as a
    where
     单位 
    in
    (select 单位  from R_YC where 姓名='胡明')
      

  5.   

    select 单位,姓名,性别,部门,职称 
    from R_YC as a
    where 单位=(select 单位 from R_YC where 姓名='胡明')
      

  6.   


    select 单位,姓名,性别,部门,职称 from R_YC as a
    where exists
    (select 1 from R_YC where 单位=a.单位,姓名=胡明)