首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 数据库 > SQL Server >

复合表 的联合 出有关问题

2012-04-13 
复合表 的联合 出问题SQL code--如下联合---没有问题,select t1.id,t1.data,t2.data from table1 t1 ,tabl

复合表 的联合 出问题

SQL code
--如下联合---没有问题,select t1.id,t1.data,t2.data from table1 t1 ,table2 t2 where t1.id=t2.id;--如果当其中一个表是 复合表时就不行了,--就是说,当其中一个表是子查询时就不行了--如下:select * from     table1 as t1,    select *from    (        select t2.id ,t2.data, t3.data from table2 as t2,table3  as t3 where t2.id=t3.id     )as tabwhere t1.id=tab.id;


[解决办法]
你忘记怎么写了。不允许将select子查询写在where上面的。
SQL code
select * from     table1 as t1,    where t1.id in     (        select t2.id  from table2 as t2,table3  as t3 where t2.id=t3.id     )
[解决办法]
SQL code
select * from     table1 as t1,    select *from    (        select t2.id ,t2.data as data1, t3.data as data2 from table2 as t2,table3  as t3 where t2.id=t3.id     )as tabwhere t1.id=tab.id;
[解决办法]
探讨
引用:
josy
(百年树人)

你的代码出错了:
如下:

SQL code

消息 156,级别 15,状态 1,第 4 行
关键字 'select' 附近有语法错误。

热点排行