网站建设资讯

NEWS

网站建设资讯

Mysql数据表怎么打8折 macbook窗口快捷键

数据库中原价格八折条件设置?

alter table 表名 add column ‘折扣’float(8,4);

创新互联坚持“要么做到,要么别承诺”的工作理念,服务领域包括:成都网站设计、网站建设、企业官网、英文网站、手机端网站、网站推广等服务,满足客户于互联网时代的调兵山网站设计、移动媒体设计的需求,帮助企业找到有效的互联网解决方案。努力成为您成熟可靠的网络建设合作伙伴!

update 表名 (‘折扣’)set ‘折扣’=原价*80%;

创建一个存储过程,将Northwinds数据库中Products表中价格全部打8折(会用到游标)

假如Products表中id是主键

创建测试表及测试数据

create table Products

(id int primary key,

price int) 

insert into Products values (1,100)

insert into Products values (2,200)

创建存储过程

create procedure p_products

as

declare @id int

declare c_pro cursor  for

select id from Products

open c_pro

fetch next from c_pro into @id

while @@fetch_status = 0

begin

update Products set price=price*0.8 where id=@id

fetch next from c_pro into @id

end

close c_pro

deallocate c_pro

执行存储过程

exec p_products

执行后表内数据

excel表中一例数据如何计算出8折的数据

如图:在另一列输入“=然后选取你需要列的第一行*0.8”,确定。下拉复制


网站题目:Mysql数据表怎么打8折 macbook窗口快捷键
当前地址:http://cdweb.net/article/ddoicee.html