在子查询上出现问题,返回的值超过1

时间:2017-05-26 07:46:13

标签: javascript sql vb.net

我已经找完整了。只需要一个敏锐的眼睛来帮助你。谢谢。

    SELECT (Select contactid from [tableA].[dbo].tableC where Company =  '" & company & "' AND empid = vProfile2.EmpNo) as contactid,vprofile2.EmpNo EmpNo, vprofile2.EmpName EmpName, upper(vprofile2.CompanyCode) CompanyCode, upper(vprofile2.DeptName) DeptName, Upper(vprofile2.JobTitle) JobTitle " & _
",Email_add Email,(Select Contact from [tableA].[dbo].tableC where Company =  '" & company & "' AND empid = vProfile2.EmpNo) as contact, " & _
"(Select Speeddial from [tableA].[dbo].tableC where Company =  '" & company & "' AND empid = vProfile2.EmpNo) as Speeddial " & _
"FROM [tableA].[dbo].tableC  RIGHT JOIN server.tableB.[dbo].[tableD] vprofile2 ON vProfile2.EmpNo = tableC.empid " & _
" AND tableC.company=vProfile2.CompanyCode " & _
"Inner JOIN server.tableB.[dbo].[tbEmail] vEmail ON vProfile2.EmpNo= vEmail.Emp_No " & _
  "WHERE(vprofile2.EmpNo Is Not null) And " & _
"vProfile2.CompanyCode = '" & company & "' " & _
 "ORDER by EmpName "

我收到错误,我试图找到正在发生的事情。

  

子查询返回的值超过1。当子查询遵循=,!=,<,< =,>,> =或子查询用作表达式时,不允许这样做。

1 个答案:

答案 0 :(得分:0)

这意味着您已使用子查询返回字段的值,并且该子查询可以返回每行多个记录:

(Select Speeddial from [tableA].[dbo].tableC where Company =  '" & company & "' AND empid = vProfile2.EmpNo) as Speeddial 

您确定此where子句只会为主查询中的每条记录返回一个(或零)结果吗?