select a,(select b from table2 where table2.a=table1.a ) c from table1; --------------------------------------------------------------------------------- 服务器: 消息 512,级别 16,状态 1,行 1 子查询返回的值多于一个。当子查询跟随在 =、!=、<、<=、>、>= 之后,或子查询用作表达式时,这种情况是不允许的。
select a,(select b from table2 where table2.a=table1.a ) from table1
select a,(select b from table2 where table2.a=table1.a ) c from table1
select table1.a,table2.b from table1,table2 where table2.a=table1.a
感谢各位在短短分钟的回复,但是 我用上面的语句,执行后得到的结果如下: 服务器: 消息 512,级别 16,状态 1,行 1 子查询返回的值多于一个。当子查询跟随在 =、!=、<、<=、>、>= 之后,或子查询用作表达式时,这种情况是不允许的。是什么问题?我用的是sql server 2000 standard edition。
select a,(select top 1 b from table2 where table2.a=table1.a ) c from table1select a,(select max(b) from table2 where table2.a=table1.a ) c from table1select a,(select count(b) from table2 where table2.a=table1.a ) c from table1
select a,(select b from table1,table2 where table2.a=table1.a) c from table
select t1.a,t2.b from table1 t1 inner join table2 on t1.a=t2.a
select a,(select top 1 b from table2 where table2.a=table1.a ) c from table1
下面是oracle执行的结果,参考一下,谢谢! SQL> select a,cursor (select b from table2 where table2.a=table1.a ) test from t able1;A TEST -- -------------------- aa CURSOR STATEMENT : 2CURSOR STATEMENT : 2B -- a1 a2 a3bb CURSOR STATEMENT : 2CURSOR STATEMENT : 2B -- b1 b2
select Table1.a,Table2.b from table1 full join table2 on table2.a=table1.a
select a,(select b from table2 where table2.a=table1.a ) c from table1;
---------------------------------------------------------------------------------
服务器: 消息 512,级别 16,状态 1,行 1
子查询返回的值多于一个。当子查询跟随在 =、!=、<、<=、>、>= 之后,或子查询用作表达式时,这种情况是不允许的。
我用上面的语句,执行后得到的结果如下:
服务器: 消息 512,级别 16,状态 1,行 1
子查询返回的值多于一个。当子查询跟随在 =、!=、<、<=、>、>= 之后,或子查询用作表达式时,这种情况是不允许的。是什么问题?我用的是sql server 2000 standard edition。
SQL> select a,cursor (select b from table2 where table2.a=table1.a ) test from t
able1;A TEST
-- --------------------
aa CURSOR STATEMENT : 2CURSOR STATEMENT : 2B
--
a1
a2
a3bb CURSOR STATEMENT : 2CURSOR STATEMENT : 2B
--
b1
b2
full join
table2 on table2.a=table1.a