begin
set @iNextId = 0;
update chain_order_number con set iNextId = con.next_id = con.next_id + 1 where con.branch_id = 1 and con.table_type = 2;
end我是想在更新next_id后并得到它的值,但执行后提示iNextId未知列?
set @iNextId = 0;
update chain_order_number con set iNextId = con.next_id = con.next_id + 1 where con.branch_id = 1 and con.table_type = 2;
end我是想在更新next_id后并得到它的值,但执行后提示iNextId未知列?
解决方案 »
- com.mysql.jdbc.CommunicationsException: Communications link failure
- PostgreSQL 与 MySQL 性能大测试(是不是比多了)
- 问个突然断电引起的问题
- 查询问题
- LOAD DATA INFILE 语句如何同时支持两种分隔符
- 向responses表插入数据总是报:unknown column 'sysdate' in 'field list'。???急
- 查询语句的问题
- 奇怪的MYSQL问题?
- 新手请教!mysql数据库下user表问题!
- 求将这个MS-SQL语句改成MySql语句
- 请教开发人员如何学习MySQL
- NSIS 安装 MyODBC 的问题
在TRIGGER中得到更新next_id后的值
`id` int(11) NOT NULL auto_increment,
`network_id` int(11) NOT NULL,
`branch_id` int(11) NOT NULL,
`table_type` int(11) NOT NULL,
`next_id` int(11) NOT NULL,
`prefix` varchar(15) NOT NULL,
PRIMARY KEY (`id`),
KEY `network_id` (`network_id`),
KEY `branch_id` (`branch_id`),
CONSTRAINT `chain_order_number_ibfk_2` FOREIGN KEY (`branch_id`) REFERENCES `chain_branch` (`branch_id`),
CONSTRAINT `chain_order_number_ibfk_1` FOREIGN KEY (`network_id`) REFERENCES `sns_network_extend` (`network_id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;上面的SQL是sql server 的,我只是想看看mysql 能不能实现?
iNextId 不是chain_order_number表的字段,只是想用它来存储更新后的值
begin
set @iNextId = 0;
update chain_order_number con set iNextId = con.next_id = con.next_id + 1 where con.branch_id = 1 and con.table_type = 2;
end更新next_id的时候把值保存到iNextId中