表1:
id,name,status
表2:
pid ,datetimes想要提取显示表1的id,name等信息,条件是表1的status=0,表2的datetimes时间大于自己指定的一个时间,表1的id和表2的pid是关系
解决方案 »
- 关于使用JOIN的问题
- sqlserver2008还原到sqlserver2005的办法
- 数据库设计问题
- sql server关于合并列的问题
- 请问SQL SERVER2000 内如何发送邮件和接收邮件(及附件)?
- 怪事了,我的插入语句分不出字符与数字了呀??
- 合并复制突然发生错误"进程未能查询在publisher上的行元数据"
- 关于ADO中通过command命令调用sql server中的存储过程的问题
- 必给分,数据库
- 往SQL SERVER 中的Image字段写入图像文件,为什么写不进去呢?50分
- “update 表 set 字段='' where 1=2”这个语句锁表不行。请高手帮忙
- 高手请进,求一条sql查询!
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>'指定时间'
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)
inner join 表2 as b on a.id=b.pid
where a.status=0 and b.datetimes>'指定时间'