select TimeSection.TimeSectionName,DayInfo.DayName ,Course.CousrseName 
from Arrange right join Course on Arrange.CourseID= Course.ID ,TimeSecton WeekInfo  
where Arrange.TimeSectionID= TimeSection.ID and Arrange.DayID= DayInfo.ID

解决方案 »

  1.   

     
    select T.TimeSectionName,D.DayName ,C.CousrseName 
    from Arrange A LEFT JOIN Course C ON A.COURSEID = C.ID 
                   LEFT JOIN TimeSecton T ON A.TimeSectionID = T.ID 
                   LEFT JOIN DAYINFO D ON A.DAYID = D.ID   
     
      

  2.   

    怎么SQL 标签不起作用了?
      

  3.   

    貌似不行啊 和我自己写的结果是一样的,港发现我贴上的代码有问题,写错了一个select TimeSection.TimeSectionName,DayInfo.DayName ,Course.CousrseName
    from Arrange ,Course,TimeSecton ,DayInfo
    where Arrange.TimeSectionID= TimeSection.ID and Arrange.DayID= DayInfo.ID and Arrange.CourseID= Course.ID 
      

  4.   

    附上生成数据库(SQL Server 2005)的语句:/*==============================================================*/
    /* DBMS name:      Microsoft SQL Server 2005                    */
    /* Created on:     2009/6/12 21:52:28                           */
    /*==============================================================*/
    if exists (select 1
                from  sysobjects
               where  id = object_id('Arrange')
                and   type = 'U')
       drop table Arrange
    goif exists (select 1
                from  sysobjects
               where  id = object_id('Course')
                and   type = 'U')
       drop table Course
    goif exists (select 1
                from  sysobjects
               where  id = object_id('DayInfo')
                and   type = 'U')
       drop table DayInfo
    goif exists (select 1
                from  sysobjects
               where  id = object_id('TimeSection')
                and   type = 'U')
       drop table TimeSection
    go/*==============================================================*/
    /* Table: Arrange                                               */
    /*==============================================================*/
    create table Arrange (
       ID                   int                  identity,
       CourseID             int                  null,
       DayID                int                  null,
       TimeSectionID        int                  null,
       constraint PK_ARRANGE primary key (ID)
    )
    go/*==============================================================*/
    /* Table: Course                                                */
    /*==============================================================*/
    create table Course (
       ID                   int                  identity,
       CourseName           nvarchar(10)         null,
       constraint PK_COURSE primary key (ID)
    )
    go/*==============================================================*/
    /* Table: DayInfo                                               */
    /*==============================================================*/
    create table DayInfo (
       ID                   int                  identity,
       DayName              nvarchar(10)         null,
       constraint PK_DAYINFO primary key (ID)
    )
    go/*==============================================================*/
    /* Table: TimeSection                                           */
    /*==============================================================*/
    create table TimeSection (
       ID                   int                  identity,
       TimeSectionName      nvarchar(10)         null,
       constraint PK_TIMESECTION primary key (ID)
    )
    go
      

  5.   

    呵呵 弄出来了 只是不太明白什么意思谢谢你们啊 select T.TimeSectionName,D.DayName,C.CourseName from  TimeSection T left join  DayInfo D on T.ID>0
    left join  Arrange A on A.TimeSectionID = T.ID AND A.DayID = D.ID 
          left join Course C on A.CourseID = C.ID