頁面展示多表join的sql

wisdomone1發表於2010-07-06
create view v_qa_plaza_index_allquestion
as
select
      g.gradename,
       s.subjectname,
       q.question_title,
       P.NICKNAME,
       T.BROWSE_COUNT,
       q.question_status,
       t.latest_update_time      
from e_parentlogininfo p, e_subjectinfo s, q_questioninfo q, q_question_stat t, e_gradeinfo g
       where Q.QUESTION_ID = P.LOGINID
       and Q.SUBJECT_ID = S.SUBJECTID
       and Q.STAGE_ID = G.GRADEID
       and Q.QUESTIONID = T.QUESTIONID
              
union all
select
      g.gradename,
       s.subjectname,
       q.question_title,
       P.NICKNAME,
       T.BROWSE_COUNT,
       q.question_status,
       t.latest_update_time      
from e_logininfo p, e_subjectinfo s, q_questioninfo q, q_question_stat t, e_gradeinfo g
       where Q.QUESTION_ID = P.LOGINID
       and Q.SUBJECT_ID = S.SUBJECTID
       and Q.STAGE_ID = G.GRADEID
       and Q.QUESTIONID = T.QUESTIONID
union all      
select
      g.gradename,
       s.subjectname,
       q.question_title,
       P.NICKNAME,
       T.BROWSE_COUNT,
       q.question_status,
       t.latest_update_time      
from e_teacherlogininfo p, e_subjectinfo s, q_questioninfo q, q_question_stat t, e_gradeinfo g
       where Q.QUESTION_ID = P.LOGINID
       and Q.SUBJECT_ID = S.SUBJECTID
       and Q.STAGE_ID = G.GRADEID
       and Q.QUESTIONID = T.QUESTIONID

來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/9240380/viewspace-667303/,如需轉載,請註明出處,否則將追究法律責任。

相關文章