数据库系统原理与设计——投影运算、选择运算
admin
2023-02-08 06:00:04
0

书籍:数据库系统原理与设计(第3版)——万常选 廖国琼等编著

数据库版本: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区间的分数

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

实战技巧:完成一个任务,可以使用两种方法来完成。



相关内容

热门资讯

专访王虹:从北大数学系曾经的“... “获奖挺好的。”王虹说话慢慢的,随后话锋一转,带着自嘲式的笑意,“但是题该做不出来,还是做不出来。”...
意大利纵火犯用猫助燃,当地动保... 【环球时报记者 林泽宇 环球时报特约记者 文简】据《意大利晨报》23日报道,近日意大利南部野火肆虐。...
第8国?美媒爆料:美政府正研究... 【环球时报综合报道】据美国《华盛顿邮报》23日报道,多名美国官员透露,美政府正研究是否在西非国家马里...
男子在采血站采血后口吐白沫、神... 7月23日,山西广播电视台《慧帮忙》栏目报道“我弟弟在霍州康宝生物科技采血站采血后口吐白沫、神志不清...
“安全先生”,不安全了 当地时间7月17日凌晨,以色列第25届议会以62票赞成、0票反对通过一项有关政党经费法的相关修正案,...
“AI科学家”,实验效率直接“... □ 本报记者 洪叶 徐春晖 窗明几净的空间里没有科研人员,取而代之的是一排充满科技感的自动化岛台,背...
云南一女子电脑屏内现“蚂蚁窝”... 大家平时清洁电脑显示屏吗? 你见过显示屏里进蚂蚁吗? 据媒体报道,云南临沧一名女子近期发现,自己使...
便携脑电采集新品发布,脑电信号... 一根发带将一个比硬币略大的采集设备贴在额头,就能实现脑电信号采集,脑机接口创新企业神舞科技7月22日...
工业和信息化部:依托标准牵引智... 日前,在北京举办的《人工智能 智能体互联》系列标准应用推进专题会上,工业和信息化部科技司副司长甘小斌...