select id,name,
(select personName from Personnel where PerID in(select PerID from PersonJob where JobID=1 and iD=8)) as corpration 
from 表A where id=8出错:
子查询返回的值多于一个。当子查询跟随在 =、!=、<、<=、>、>= 之后,或子查询用作表达式时,这种情况是不允许的。因为 (select personName from Personnel where PerID in(select PerID from PersonJob where JobID=1 and iD=8)  中personName 有两条想得到的结果:
id name personname
8  国美   PerA
8  国美   PerBselect personName from Personnel where PerID in(select PerID from PersonJob where JobID=1 and iD=8)
不能取出一条,有多条就取出

解决方案 »

  1.   

     select id,name,
    (select top 1 personName from Personnel where PerID in(select PerID from PersonJob where JobID=1 and iD=8)) as corpration 
    from 表A where id=8
      

  2.   

    select id,name,
    (select top 1 personName from Personnel where PerID in(select PerID from PersonJob where JobID=1 and iD=8)) as corpration 
    from 表A where id=8
      

  3.   

    select a.id,a.name,b.personNamefrom 表A a,
    (select personName from Personnel where PerID in(select PerID from PersonJob where JobID=1 and iD=8)) as bwhere a.id=8
      

  4.   

    select a.id,a.name,b.personName from 表A a, 
    (select id,personName from Personnel where PerID in(select PerID from PersonJob where JobID=1 and iD=8)) as b where a.id = b.id and  a.id=8
      

  5.   

    怎么没看见
    表A和Personnel 表的关系字段??
      

  6.   

    表A和Personnel  没联系 谢谢
      

  7.   

    to happyflystone (select personName from Personnel where PerID in(select PerID from PersonJob where JobID=1 and iD=8)) as bb 不是表
      

  8.   

    to happyflystone  对象名 b.personName 无效