반응형
use test;
drop table if exists xxx_user;
create table xxx_user (
usn int not null auto_increment
, money int not null
, grade char(1) not null
, reg_date datetime
, primary key (usn)
) engine=innodb default charset=utf8mb4;
insert into xxx_user values (null, 1000, 'A', now()), (null, 2000, 'B', now()), (null, 3000, 'C', now());
select * from xxx_user;
set @uv_money_old := -999, @uv_money_new := -999;
select @uv_money_old, @uv_money_new;
select * from xxx_user where usn = 1;
update xxx_user
set money = (@uv_money_new := (@uv_money_old := money) - 50)
, grade = 'Z'
where usn = 1;
select * from xxx_user where usn = 1;
select @uv_money_old, @uv_money_new;
반응형
'연구개발 > MYSQL' 카테고리의 다른 글
innodb flush (0) | 2015.03.05 |
---|---|
IN ( ) 절에 Multiple 인자값 넣어 조회 (ex. where id in (12, 34, 56) ) (0) | 2015.03.03 |
MRU LRU (0) | 2015.03.03 |
index hit (0) | 2015.03.02 |
날짜 및 시간설정 (0) | 2015.02.26 |