主题:asp读取两个表的问题
new911
[专家分:0] 发布于 2007-12-29 17:11:00
sql = "select * from gongzuo,sc where gongzuo.id=sc.shuid and gongzuo.id="&xmid
我同时读取两个表gongzuo sc
我要让gongzuo.id=sc.shuid 但有可能表sc的shuid没有与表gongzuo对应的值,我该如何写? [em10]
我是要如果没有对应的值就取消这个条件gongzuo.id=sc.shuid。就直接是条件gongzuo.id="&xmid 读取表gongzuo的内容
回复列表 (共5个回复)
沙发
a97191 [专家分:4040] 发布于 2007-12-29 17:53:00
参考一下
declare @gongzuo table(id int,cno int,degree int)
insert @gongzuo select 103, 245, 86
union all select 105, 245, 75
union all select 109, 245, 68
union all select 108, 166, 81
union all select 107, 166, 75
union all select 101, 166, 79
declare @sc table(shuid int,cno int,degree int)
insert @sc select 103, 245, 86
union all select 106, 245, 75
union all select 103, 245, 68
union all select 102, 166, 81
union all select 107, 166, 75
union all select 101, 166, 79
select *from @gongzuo a where not EXISTS
(SELECT *
FROM @sc where shuid =a.id) and id=109
板凳
new911 [专家分:0] 发布于 2007-12-30 09:37:00
是这样写吗?
sql = "select * from @gongzuo where not EXISTS (select * from @sc where shuid=gongzuo.id) and id="&xmid
好象还不行,麻烦帮下忙,asp我比较少用
3 楼
martine [专家分:4950] 发布于 2007-12-30 11:47:00
先用一个SEL 找到一个,再
用一个SEL 找另一个,然后对照.
4 楼
new911 [专家分:0] 发布于 2007-12-30 14:38:00
具体怎么写呢?
5 楼
a97191 [专家分:4040] 发布于 2007-12-31 10:02:00
最好是设置带有数据表,然后是你所要的结果,我这样说我的不清你到底要什么
我来回复