页数:21页文件大小:1.77 MB来源: 数据库技术ppt课件
本课件讲解在MS SQL Server中更新与查询数据的方法,说明用INSERT语句与企业管理器添加记录、用DROP与ALTER删除修改表,并演示多表连接、列别名、ORDER BY排序与取出不重复记录的操作。
第十四讲MS SQL Server
本讲内容
数据库更新与查询
向表中添加数据
删除和修改表
查询数据
操作多个表
操作多个表:作者表、书名表与titleauthor表三表等值连接。
select au_fname,title from authors,titles,titleauthor where authors.au_id=titleauthor.au_id and titles.title_id=titleauthor.title_id两表连接:
select title,pub_name from titles,publishers where titles.pub_id=publishers.pub_id改变显示方式
操作字段
操作字段:对列进行算术运算。
select price*2 from titles字段标题名称的改变——列的别名:
select price "Original price", price*2 "NewPrice" from titles操作字段:用别名命名计算列。
select price * ytd_sales "total revenue" from titles排序查询结果
排序查询结果:
select au_lname,au_fname from authors order by au_lname,au_fname排序查询结果:带 WHERE 条件与降序排列。
select au_lname,au_fname from authors where au_lname='Ringer' order by au_lname,au_fname desc取出互不相同的记录
数据库访问
下载地址:{{downurl}}
{{{a}}}
{{#b}}{{{b}}}
{{/b}} {{/title}} {{#nolog}}登陆注册
{{/nolog}} {{#djsx}}点我刷新
{{/djsx}} {{#gocz}} {{/gocz}} {{#ffqr}} {{/ffqr}}