一、實驗目的
通過本次實驗使學生掌握資料庫中表資料的各種複雜查詢操作。
二、實驗內容
1、連線查詢
2、巢狀查詢
3、謂詞查詢
三、實驗環境
1、windows
2、sql server
四、實驗步驟及結果
1、建立乙個資料庫,檔名為「教學」
create database teach;
2、開啟「教學」資料庫
use teach;
3、輸入如下資料:
s表create table s(
s# varchar(20),
sname varchar(20),
age int,
*** varchar(20));
s# sname age ***
s1 wang 15 男
s2 li 17 女
s3 lu 19 女
s4 zhao 13 女
s5 yang 20 男
c表create table c(
c# varchar(20),
cname varchar(20),
t# varchar(20));
c# cname t#
c1 maths t1
c2 db t2
c3 english t3
c4 computer t2
sc 表
create table sc(
s# varchar(20),
c# varchar(20),
score int);
s# c# score
s1 c1 50
s2 c1 70
s3 c1 80
s4 c1 75
s5 c1 87
s1 c2
s2 c2
s4 c2 85
s1 c3
s5 c4 60
s4 c4 45
t表create
資料庫複雜查詢
查詢a表的最後一次新增的資料 select a.from a a,select t.userid id,max t.timer ti from select from tablename where createtime between to date 2018 04 01 yyyy mm dd a...
資料庫中表的複雜查詢 分頁
一 資料庫中表的複雜查詢 1 連線查詢 1.0連線的基本的語法格式 from table1 join type table2 on join condition where query condition table1 左表 table2 右表 join type 連線的型別。交叉 內連線 左外連線...
資料庫 實驗二 資料庫的簡單查詢和連線查詢實驗
l 用transact sql語句表示下列操作 在學生選課庫中實現其資料查詢操作 求數學系學生的學號和姓名。select sno,sname from student where sdept ma 求選修了課程的學生學號。select distinct sno from sc 求選修c1課程的學生學...