数据库操作7.2

标签: update  
2011-05-02 10:17 阅读(?)评论(0)

    update语句

 

update语句语法:

update {<table name|view name>}

set

{<column name>=<expression>

[....,<last column name>=<last expression>]

[where <search condition>]

}

1、update语句更新列值

update tb_student12

set 学号=left(学号,2)+'1'+right(学号,4)

where 专业名='计算机'

2、利用子查询更新多行的值

update tb_grade12

set 成绩=成绩+10

where 学号 in

(

select 学号from tb_student12 where 专业名='计算机') and 课程号='01'

3、使用case表达式更新列值

update tb_case12

set 消费水平=

case when 商品价钱>2000 then '昂贵'

when (商品价格>=800) and (商品名称<=2000) then '一般'

end

4、只更新存在于其它表中的数据

update tb_update12 set 浮动工资=200

where 职工姓名 in

(

select 姓名 from tb_personnel12

)

   阅读(?)评论(0)
上一篇: 数据库操作7.3 下一篇:数据库操作7.1
 
表  情:
加载中...
 

请各位遵纪守法并注意语言文明