我现在有6张表. 
province省市表 
college学校表, 
school机构表,上级关联id为college_id,在这张表中,同时有自己的上下级记录.比如说:学院,院属系,都存在这张表里,院属系是学院的下级. 
specialty专业,上级关联id为school_id 
base, 
sub_school这2个表的上级均为college_id 我如何建立一个视图,为下面的格式: 省市id,学校id,学校name,机构id,机构name,专业id,专业name,base_id,base_name,sub_school_id,sub_school_name,id,name,kind(类型) 也就是说.通过省市,能够查到下面所有的学校,机构等等. 
通过学校,能够查到下面所有的机构,专业等等. 

解决方案 »

  1.   

    不知道是不是这个意思,试试看~~
    select *
      from province p,
           college c,
           school s,
           specialty sp,
           base b,
           sub_school ss
     where p.province_id = c.province_id
       and c.college_id = s.college_id
       and s.school_id = sp.school_id
       and b.college_id = c.college_id
       and ss.college_id = c.college_id;