1
CREATE VIEW `report_central_class` AS
SELECT a.*,b.course_title,b.outline_id,c.catid,d.main_title,
      (select comp_name 
       from lang_company_details 
       where comp_id = (select comp_id 
                        from lang_company_details_courses 
                        where course_id=a.course_id)
       ) as company, 
       (select concat(fname,' ',lname) 
        from lang_course_instructors 
        where slno=a.class_inst_id) as instname 
FROM `lang_course_details_session` as a, 
              `lang_course_details` as b,
              `lang_course_outline` as c,  
              `lang_course_category` as d 
where a.`class_status` != '' and 
      a.course_id=b.course_id and 
      c.outline_id=b.outline_id and 
      c.catid=d.slno;

如果我在没有创建视图语句的情况下运行此查询,那么它将从数据库中返回正确的记录。但是当我尝试从 VIEW 运行相同的内容时,它显示子查询返回多行。

这个问题在子查询中:

( select comp_name 
  from lang_company_details 
  where comp_id = (
    select comp_id 
    from lang_company_details_courses 
    where course_id=a.course_id
  )
) as company 

如果我要删除此查询,则一切正常,但使用此查询,视图不起作用。

4

0 回答 0