我想更新表中某行中的某几列,更新完后,要得到这行的所有列,如何用一个sql 语句实现。谢谢create table role
(
id int not null auto_increment,
roleid int,
silver int,
gold int,
primary key (id)
)update role set gold=gold+100 where roleid=1;
select * from role where roleid=1;
以上2个语句合并
(
id int not null auto_increment,
roleid int,
silver int,
gold int,
primary key (id)
)update role set gold=gold+100 where roleid=1;
select * from role where roleid=1;
以上2个语句合并
第二,注意语句规范,手册中说明,请使用大写.类同这样的可以合并
update role set gold=gold+100 where roleid = (SELECT wcid FROM WC WHERE roleid = '1');
create procedure updateAndBack(in cId int)
begin
set @mySql = concat('update role set gold=gold+100 where roleid=',cId);
prepare stmt from @mySql;
execute stmt; set @mySql = concat('select * from role where roleid=',cId);
prepare stmt from @mySql;
execute stmt;
end调用时call updateAndBack(1)即可。