违法℃玩家 发表于 2016-10-19 09:12:18

MySQL update && select ,update的同时select,和for update 语句说再见。

  MySQL update && select
  

  CREATE TABLE `testupdate` (
`id` bigint(20) NOT NULL AUTO_INCREMENT,
`val` bigint(20) NOT NULL DEFAULT '0',
PRIMARY KEY (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=2 DEFAULT CHARSET=utf8

  

  update testupdate
set val = val+1
where id = 1 and @value := val+1;

  select @value;
  

  
页: [1]
查看完整版本: MySQL update && select ,update的同时select,和for update 语句说再见。