溫馨提示×

溫馨提示×

您好,登錄后才能下訂單哦!

密碼登錄×
登錄注冊×
其他方式登錄
點擊 登錄注冊 即表示同意《億速云用戶服務條款》

數(shù)據庫系統(tǒng)原理與設計——投影運算、選擇運算

發(fā)布時間:2020-07-23 19:19:05 來源:網絡 閱讀:1124 作者:sky9890 欄目:關系型數(shù)據庫

書籍:數(shù)據庫系統(tǒng)原理與設計(第3版)——萬常選 廖國瓊等編著

數(shù)據庫版本:SQL Server 2005

/*

select courseNO as 課程號,lower(coursename) 課程名,courseHour/16 as 周課時

from course

*/

/*  --”%任意字符","_"通配符的使用

select *

from class

where className  like '%會計%'

select studentNo,studentName

from Student

where studentName like '王__'

select studentNo,studentName

from Student

where studentName not like '%福%'

select studentNo,studentName,nation

from Student

where nation  not like '蒙古族'

select studentNo,studentName,nation

from Student

where nation like '蒙古族' 

*/

--通配符的使用

/*

select className

from class

where className like '%16\_%' ESCAPE '\'

union

select className

from class

where className like '%16\_%'  --不對

union

select className

from class

where className like '%16_%' ESCAPE '\'  --不對

*/

--轉義字符的使用,以下兩種方法相似

/*

select className

from class

where className like '%16#_%' escape '#'

select className

from class

where className like '%16\_%' ESCAPE '\'

*/

/* --學會邏輯運算符or  and 

select studentNo,courseNO,score

from score

where courseNo='001' or courseNo='005' or courseNo='003'

select studentNo,courseNO,score

from score

where courseNo='001' and  courseNo='003'

select studentNo,courseNO,score

from score

where courseNo in('001','005','003')

*/

/*

select studentNO as 學號,studentName as 姓名 ,year(birthday) as 出生年份

from Student

where year(birthday)=1998 and nation='漢族'

*/

/*  --籍貫不在南昌和上海的,兩種實施方法,二選一

select studentNO as 學號,studentName as 姓名 ,native

from Student

where native not in ('南昌','上海')

select studentNO as 學號,studentName as 姓名 ,native

from Student

where  native!='南昌' and native!='上海'

*/

/*  80——90區(qū)間的分數(shù)

select studentNo,courseNO,score

from score

where  score>=80 and  score<=90

select studentNo,courseNO,score

from score

where  score between 80 and 90

*/

/*

select studentNo,courseNO,score

from score

where score<80 or score>90

*/

/*

--按籍貫排序

select studentName,native,classNo

from student

where native!='南昌' and native!='上海'

order by native desc 

*/

該教材相關資料請點擊如下鏈接:

https://blog.51cto.com/sky9896/2323447

http://down.51cto.com/data/2456174

實戰(zhàn)技巧:完成一個任務,可以使用兩種方法來完成。



向AI問一下細節(jié)

免責聲明:本站發(fā)布的內容(圖片、視頻和文字)以原創(chuàng)、轉載和分享為主,文章觀點不代表本網站立場,如果涉及侵權請聯(lián)系站長郵箱:is@yisu.com進行舉報,并提供相關證據,一經查實,將立刻刪除涉嫌侵權內容。

AI