- 1、原创力文档(book118)网站文档一经付费(服务费),不意味着购买了该文档的版权,仅供个人/单位学习、研究之用,不得用于商业用途,未经授权,严禁复制、发行、汇编、翻译或者网络传播等,侵权必究。。
- 2、本站所有内容均由合作方或网友上传,本站不对文档的完整性、权威性及其观点立场正确性做任何保证或承诺!文档内容仅供研究参考,付费前请自行鉴别。如您付费,意味着您自己接受本站规则且自行承担风险,本站不退款、不进行额外附加服务;查看《如何避免下载的几个坑》。如果您已付费下载过本站文档,您可以点击 这里二次下载。
- 3、如文档侵犯商业秘密、侵犯著作权、侵犯人身权等,请点击“版权申诉”(推荐),也可以打举报电话:400-050-0827(电话支持时间:9:00-18:30)。
- 4、该文档为VIP文档,如果想要下载,成为VIP会员后,下载免费。
- 5、成为VIP后,下载本文档将扣除1次下载权益。下载后,不支持退款、换文档。如有疑问请联系我们。
- 6、成为VIP后,您将拥有八大权益,权益包括:VIP文档下载权益、阅读免打扰、文档格式转换、高级专利检索、专属身份标志、高级客服、多端互通、版权登记。
- 7、VIP文档为合作方或网友上传,每下载1次, 网站将根据用户上传文档的质量评分、类型等,对文档贡献者给予高额补贴、流量扶持。如果你也想贡献VIP文档。上传文档
查看更多
chp4T—SQL语言基础
Chp4 T-SQL语言基础;主要内容;常量和变量;常量;变量;局部变量;全局变量;练习;运算符和表达式;常规方式
use pubs
go
select pub_id,pub_name,country
from publishers
go;用*表中所有的列
select *
from authors
使用top关键字
eg1: select top 6 *
from authors
eg2: select top 10 percent *
from authors
;使用distinct关键字
eg1: select state from authors
eg2: select distinct state from authors
eg3: select distinct state,city
from authors
eg4: select state,city from authors;使用计算列
eg1: select title_id,price,price*0.7
from titles
eg2: select au_lname+.+au_fname,city+,+state
from authors;
eg1: select title_id代号,price原价,price*0.7现价
from titles
eg2: select title_id as 代号,price as 原价,price*0.7 as现价
from titles
eg3: select 代号 =title_id, 原价= price, 现价 =price*0.7
from titles
eg4: select title_id 代号,price 原价,price*0.7 现价
from titles;语法格式为:
ORDER BY 表达式1 [ASC|DESC][,表达式2[ASC|DESC][,…n]]
select * from titles
order by price
select * from titles
order by price asc
select * from titles
order by price desc
;
select * from titles
order by type,price
;练习1;练习2;练习3;
;select * from titles
where type=business and price10
select * from titles
where price20 or price10
select * from titles
where not (price10 and price20);使用between关键字
查询书价在15和20员之间的图书
select title,price
from titles
where price between 15 and 20
等价于:
select title,price
from titles
where price =15 and price=20 ;select title,price
from titles
where price not between 15 and 20
等价于:
???;使用in关键字
select *
from authors
where state in(CA,KS,MI,IN)
select *
from authors
where state =CAor state=KSor state=MIor state=IN;练习4;通配符%
表示0~n个任意字符
select au_lname,au_fname from authors
where au_fname like D%
select * from titles
where title like %Computer%;通配符_(下划线)
表示单个字符
select au_lname,au_fname, phone, au_id
from authors
where au_id like ‘72_-%’
select au_lname,au_fname, phone, au_id
from authors
where au_id like _7%
;通配符[ ]
方括号列出的任意一个字符
select au_lname,au_lname, phone, au_id
fr
文档评论(0)