回 帖 发 新 帖 刷新版面

主题:asp读取两个表的问题

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个回复)

沙发

参考一下
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

板凳

是这样写吗?
sql = "select * from @gongzuo where not EXISTS (select * from @sc where shuid=gongzuo.id) and id="&xmid
好象还不行,麻烦帮下忙,asp我比较少用

3 楼

先用一个SEL 找到一个,再
用一个SEL 找另一个,然后对照.

4 楼

具体怎么写呢?

5 楼

最好是设置带有数据表,然后是你所要的结果,我这样说我的不清你到底要什么

我来回复

您尚未登录,请登录后再回复。点此登录或注册