在使用同一个数据库中链接2个表一般使用union关键字,同样在不同的数据库间也可以使用它.

我 这里有一个例子,大家只要把不同的地方替换就可使用.

sql="SELECT bul_id id,room_id roomid,owrbul_date,owrbul_title,flag='comm'  FROM today_happy."&session

("cityname")&".dbo.tb_bul where room_id=2 and state=1 and owrstate=0 union all select id,roomId,askingDate

owrbul_date,askingTitle owrbul_title,flag='steet' from today_happy.streets.dbo.ownerAsking where roomid="&session

("room_id") 

其中注意:
                  today_happy   数据库服务器名称

                  streets             数据库名 

                  dbo                用户名

                  ownerAsking  表名

试一下吧

posted on 2007-01-26 13:37  站得更高,看得更远  阅读(337)  评论(0)    收藏  举报