注册 登录
编程论坛 ASP技术论坛

表1 left join 表2,表2是查询怎么办

robin_fan 发布于 2012-03-30 14:25, 449 次点击
如题access联合:   select 表1.id from 表1 left join 表2 on。。。
如果表2是select 。。。查询怎么办? 能嵌套进去吗?
2 回复
#2
孤独冷雨2012-03-30 19:01
select * from(select id as a,name as b,'1'  as c from table1 union select id as a,name as b,'2' as c from table2)

if rs("c")=1 then

    response.write rs("b") '表一的内容

else

    response.write rs("b") '表二的内容

end if

字段类型要一样
要查什么条件后面写上。可以在一个页面上循环输出两张表不同的内容!
#3
孤独冷雨2012-03-30 19:01
select * from(select id as a,name as b,'1'  as c from table1 union select id as a,name as b,'2' as c from table2)

if rs("c")=1 then

    response.write rs("b") '表一的内容

else

    response.write rs("b") '表二的内容

end if

字段类型要一样
要查什么条件后面写上。可以在一个页面上循环输出两张表不同的内容!
1