MySQL update && select ,update的同时select,和for update 语句说再见。
2013-04-23 17:35
736 查看
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;
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;
相关文章推荐
- MySQL update && select ,update的同时select,和for update 语句说再见。
- Mysql中You can't specify target table for update in FROM clause错误的意思是说,不能先select出同一表中的某些值,再update这个表(在同一语句中)。
- mysql SELECT FOR UPDATE语句使用示例
- mysql SELECT FOR UPDATE语句使用示例
- Mysql查询语句使用select.. for update导致的数据库死锁分析
- Mysql查询语句使用select.. for update导致的数据库死锁分析
- mysql SELECT FOR UPDATE语句使用示例
- MySQL SELECT FOR UPDATE语句使用示例
- mysql SELECT FOR UPDATE语句使用示例
- mysql 事务是专门用来管理insert,update,delete语句的,和select语句一点不相干
- SELECT 语句中的 for update (以及 lock in share mode
- mysql事务,select for update,及数据的一致性处理
- select语句后以for update结尾
- 巧用 MySQL 自定义变量一条语句实现 UPDATE + SELECT
- mysql 一个较特殊的问题:You can't specify target table '表名' for update in FROM clause
- Mysql InnoDB中的查询事务模式与锁定select ..for update
- 20.6 Select…For Update语句与锁
- select ... for update在mysql和oracle间锁行为的比较
- mysql 一个较特殊的问题:You can't specify target table 'wms_cabinet_form' for update in FROM clause
- Select For update语句浅析