access怎么查询这个 - MS-SQL Server / 基础类
and id not in (select distinct client from tb_talk where DATEDIFF('d', #"&date&"#, adddate)<=45)
这个是从tb_client中找出超过45天没有在tb_talk 有记录的数据
结果貌似是对的
但效率太低了
我想这样应该快一点
and (select 1 from em_talk where client = tb_client.id DATEDIFF('d', #"&date&"#, adddate)<=45) 不存在
但不知应该怎么写
ACCESS中不知道有没EXISTS
SQL code:
select * from tb t where ... and not exists (select * from tb_talk where DATEDIFF('d', #"&date&"#, adddate)<=45 and t.id=client)
SQL code:
and id not in (select client from tb_talk where DATEDIFF('d', #"&date&"#, adddate)<=45)--去掉distinct
and not exists (select 1 from tb_talk where client = em_client.id and DATEDIFF('d', #"&date&"#, adddate)<=45)
这样可以了
相关问答:
可能因为工作的原因 接触数据库这块比较少,之前都是做程序这块,数据库这块都有专门的人来做 分工都很明细 所以对数据库这一块完全不了解。前段时间 去面试了几家公司 几乎都是在数据库这块挂掉的 连个简单的SQ ......
今天做了一个存储过程 环境是SQL2000数据库
大致如下
建立临时表
定义员工游标
循环员工(属于1个公司)
......
现在有两张表:文章主表A(articleId,articleTitle),文章评论表B(commentId,articleId,commentTitle)
现在我想实现这样的功能:列出文章列表,其中每篇文章标题下面列出此文章的前2个文章评论,请问sql语句怎么写啊 ......
请教高手:
以下是数据库中的三条记录,英文为字段名称
id planname TaskBeginTime Status
329 2010年03 ......
求个vb中的sql语句的写法,次sql语句的用法是分页程序
我写的如下:其中A是用来接收每页显示的记录的条数,B是用来接收显示的当前的页面.
sqltext="select top A * from log where id not in(select top ( ......