書籍:數(shù)據(jù)庫系統(tǒng)原理與設(shè)計(第3版)——萬常選 廖國瓊等編著
創(chuàng)新互聯(lián)成立于2013年,是專業(yè)互聯(lián)網(wǎng)技術(shù)服務(wù)公司,擁有項目做網(wǎng)站、成都網(wǎng)站建設(shè)網(wǎng)站策劃,項目實施與項目整合能力。我們以讓每一個夢想脫穎而出為使命,1280元無極做網(wǎng)站,已為上家服務(wù),為無極各地企業(yè)和個人服務(wù),聯(lián)系電話:18980820575
數(shù)據(jù)庫版本: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 '\' --不對
*/
--轉(zhuǎn)義字符的使用,以下兩種方法相似
/*
select className
from class
where className like '%16#_%' escape '#'
select className
from class
where className like '%16\_%' ESCAPE '\'
*/
/* --學(xué)會邏輯運算符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 學(xué)號,studentName as 姓名 ,year(birthday) as 出生年份
from Student
where year(birthday)=1998 and nation='漢族'
*/
/* --籍貫不在南昌和上海的,兩種實施方法,二選一
select studentNO as 學(xué)號,studentName as 姓名 ,native
from Student
where native not in ('南昌','上海')
select studentNO as 學(xué)號,studentName as 姓名 ,native
from Student
where native!='南昌' and native!='上海'
*/
/* 80——90區(qū)間的分?jǐn)?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
*/
該教材相關(guān)資料請點擊如下鏈接:
https://blog.51cto.com/sky9896/2323447
http://down.51cto.com/data/2456174
實戰(zhàn)技巧:完成一個任務(wù),可以使用兩種方法來完成。