資源描述:
《多表查詢的sql語句舉例》由會(huì)員上傳分享,免費(fèi)在線閱讀,更多相關(guān)內(nèi)容在工程資料-天天文庫。
1、多表查詢的sql語句舉例SQL語句多表查詢SQL語句多表查詢:?jiǎn)栴}及描述:--1.學(xué)生表Student(S#,Sname,Sage,Ssex)--S#學(xué)生編號(hào),Sname學(xué)生姓名,Sage出生年月,Ssex學(xué)生性別--2.課程表Course(C#,Cname,T#)--C#--課程編號(hào),Cname課程名稱,T#教師編號(hào)--3.教師表Teacher(T#,Tname)--T#教師編號(hào),Tname教師姓名--4.成績(jī)表SC(S#,C#,score)--S#學(xué)生編號(hào),C#課程編號(hào),score分?jǐn)?shù)*/--創(chuàng)建測(cè)試數(shù)據(jù)create
2、tableStudent(S#varchar(10),Snamenvarchar(10),Sagedatetime,Ssexnvarchar(10))insertintoStudentvalues('01',N'趙雷','1990-01-01',N'男')insertintoStudentvalues('02',N'錢電','1990-12-21',N'男')insertintoStudentv
3、alues('03',N'孫風(fēng)','1990-05-20',N'男')insertintoStudentvalues('04',N'李云','1990-08-06',N'男')insertintoStudentvalues('05',N'周梅','1991-12-01',N'女')insertintoStudentvalues(
4、39;06',N'吳蘭','1992-03-01',N'女')insertintoStudentvalues('07',N'鄭竹','1989-07-01',N'女')insertintoStudentvalues('08',N'王菊','1990-01-20',N'女')createtableCourse(C#varchar(10),Cn
5、amenvarchar(10),T#varchar(10))insertintoCoursevalues('01',N'語文','02')insertintoCoursevalues('02',N'數(shù)學(xué)','01')insertintoCoursevalues('03',N'英語','03')createtableTeacher(T#varchar(10),Tnamenvarch
6、ar(10))insertintoTeachervalues('01',N'張三')insertintoTeachervalues('02',N'李四')insertintoTeachervalues('03',N'王五')createtableSC(S#varchar(10),C#varchar(10),scoredecimal(18,1))insertintoSCvalues('01','01
7、9;,80)insertintoSCvalues('01','02',90)insertintoSCvalues('01','03',99)insertintoSCvalues('02','01',70)insertintoSCvalues('02','02',60)insertintoSCvalues('02','03',80)insertintoSCvalue
8、s('03','01',80)insertintoSCvalues('03','02',80)insertintoSCvalues('03','03',80)insertintoSCvalues('04',