表1:
id,name,status
表2:
pid ,datetimes想要提取显示表1的id,name等信息,条件是表1的status=0,表2的datetimes时间大于自己指定的一个时间,表1的id和表2的pid是关系

解决方案 »

  1.   


    select a.id,a.name from 表1 as a
     inner join 表2 as b on a.id=b.pid
     and a.status=0 and b.datetimes>'指定时间'
      

  2.   

    declare @time datetime
    set @time=...select 
        a.id,a.name 
    from 
        表1 a 
    where 
        a.status=0 
        and 
        exists(select 1 from 表2 where pid=a.id and datetimes>@time)
      

  3.   

    select t1.id,t1.name from t1,t2 where t1.status=0 and t2.datetimes>'时间' and t1.id=t2.pid
      

  4.   

    select a.id,a.name from 表1 as a
     inner join 表2 as b on a.id=b.pid
     where a.status=0 and b.datetimes>'指定时间'