关于两个表联合查询的问题(50分)

  • 主题发起人 主题发起人 真水无香
  • 开始时间 开始时间

真水无香

Unregistered / Unconfirmed
GUEST, unregistred user!
我现在有个access库有两个表,一个用来记录所有成员,一个用来签到。
现在我想求出未到的成员(即所有成员表减去签到表,剩下的成员)
这样程序要如何写呢?


PS:以前遇到的都是相等(=)的查询,相减的没见过阿。而且我也试过用SQL语言中的not in 和 not exists 查询,只能找到部分内容,不全阿? 我应该怎么办? 望各位大侠多多指点!!!
 
select * from tball where username not in (select userName from tbArrived);
 
select * from 成员表 where 成员表ID not in (select 成员表ID from 签到表 where ...)
 
happycyp,kaida:
多谢两位,小弟也是这么写的,但是在结果中多一个人啊?

with ADOQuery2 do
begin
close;
sql.Clear;
sql.Add('select ID ,name from [member] where ID not in(select ID from [temporary])');
open;

end;
在temporary表中ID字段有0001,0002,0004这四个值
运行后,在later表中还有0004,为什么啊?
 
估计你的两个表中的 0004 有区别,例如前后有空格。
 
不会的
两个是完全一样的
 
应该不是sql的问题,你放在access里面执行一下看看结果对不?
 
多人接受答案了。
 
后退
顶部