oracle左外连接和子查询,sql – 左外连接子查询?

  • Post author:
  • Post category:其他


———-

User

———-

user_ID(pk)

UserEmail

———-

Project_Account

———-

actno

actname

projno

projname

ProjEmpID

ProjEmpMGRID

其中ProjEmpID,ProjEmpMGRID是user_id,ProjEmpMGRID可以为null.

我需要查找useremail并显示表project_account.我需要使用具有重复值的actNo进行查询.

我的查询是这样的:

select projno,projname,actno,actname,

(select u.user_email as project_manager from project_account c left outer join users u

on u.user_id = c.ProjEmpID where actno=’some no’)as project_manager,

(select u.user_email as program_manager from project_account c left outer join users u

on u.user_id = c.ProjEmpMGRID where actno=’someno’) as program_manager

from project_account where actno=’someno’

我在Oracle中收到的错误消息:

ora-01427 single row subquery returns

more than one row

当我的子查询返回多个电子邮件ID时,我收到此错误.正如我所说,行为不是不唯一的.我能理解错误,但我无法弄清楚解决方案.我在子查询中执行左外连接,因为prog manager id中可能有空值.

任何帮助,将不胜感激.