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
from Arrange right join Course on Arrange.CourseID= Course.ID ,TimeSecton WeekInfo
where Arrange.TimeSectionID= TimeSection.ID and Arrange.DayID= DayInfo.ID
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
from Arrange ,Course,TimeSecton ,DayInfo
where Arrange.TimeSectionID= TimeSection.ID and Arrange.DayID= DayInfo.ID and Arrange.CourseID= Course.ID
/* 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
left join Arrange A on A.TimeSectionID = T.ID AND A.DayID = D.ID
left join Course C on A.CourseID = C.ID