表A和表B的结构相同,都有两个字段:日期(datetime类型)、员工号(int类型)
现在要求做类似这样的查询:select * from 表A where 日期+员工号 in (select distinct 日期+员工号 from 表B)

解决方案 »

  1.   

    select *
    from 表A a
     inner join (select 日期,员工号 from 表B) b
     on a.日期=b.日期 and a.员工号=b.员工号
      

  2.   

    select * from 表A where eixsts (select * from 表B where 日期=表A.日期 and 员工号=表A.员工号)
      

  3.   

    select * from 表A 
    where 日期+员工号 in (select distinct 日期+员工号 from 表B)
      

  4.   

    感谢2楼的解答。
    3楼的也许能行,但似乎执行效率比较低。
    4楼的就是我写的示例,SQL不会报错,但得到的结果是不对的。