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未知列?
在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中