表A:
userid name
1 张三
2 李四
3 王五
4 赵六
5 张三
表B:
id userid countdate
1 2 2010-11-8
2 3 2010-11-8
3 4 2010-11-9
检索出userid在表A存在而表B不存在且countdate为指定日期的记录,即检索结果为:
b.userid,a.countdate
1
5
表结构及目的描述:表A是用户名,表B是在每次用户登录时写入一条记录,然后统计每天没登录系统的员工
userid name
1 张三
2 李四
3 王五
4 赵六
5 张三
表B:
id userid countdate
1 2 2010-11-8
2 3 2010-11-8
3 4 2010-11-9
检索出userid在表A存在而表B不存在且countdate为指定日期的记录,即检索结果为:
b.userid,a.countdate
1
5
表结构及目的描述:表A是用户名,表B是在每次用户登录时写入一条记录,然后统计每天没登录系统的员工
解决方案 »
- dotnetcharting 饼形图 修改百分比的字体颜色
- 新手请教一个简单问题关于dropDownList 控制更新的
- 调查 进者有分:物业管理网站
- 有办法让ListBox实现多选绑定吗?
- 请教大家关于table控件的问题,谢谢大家了
- |M| 300分 学习URL改写参数出错,和相关知识 谢谢
- .net2.0,如何根据登录用户的角色跳转到不同的页面.
- 把DropDownList的 AutoPostBack="True"设置后,如何根据DropDownlist的变化而使得广西框的内容也发生变化??
- 怎样恢复我的帮助?
- Web.Config中如何使用Mappath?
- 请教:asp.net2.0中使用了RSA加密,本地正常,传到网站后发生错误
- DIV滚动条问题
select a.userid,'' as countdate
from 表A a
where not exists (select * from 表B b where a.userid=b.userid and b.countdate='你的指定日期')
WHERE userid not in (SELECT userid FROM b WHERE countdate='2010-11-11')
这个条件好像没有什么用啊
where userid not in(select userid from b where countdate = '指定日期')其实指定日期不用在SQL中表达,因为是你要指定的日期,所以肯定是唯一的
WHERE userid not in (SELECT userid FROM b WHERE countdate='2010-11-11')
create table #A
(
userid int not null identity(1,1) primary key,
name varchar(20)
)
create table #B
(
id int not null identity(1,1) primary key,
userid int not null,
countdate datetime not null
)insert #A(name) values
('zhangsan'),
('lisi'),
('wangwu'),
('zhaoliu'),
('zhangsan')insert #B(userid,countdate)
values
(2,'2010-11-08'),
(3,'2010-11-08'),
(4,'2010-11-09')select * from #A a
where a.userid not in(select userid from #B)
drop table #A
drop table #Bthe result:
1 zhangsan
5 zhangsan
符合了检索出userid在表A存在而表B不存在
那你的答案是要countdate,这个字段在B表中