I'm trying to write a Mysql Stored Procedure that returns two values after inserting a r开发者_如何学运维ecord. I want it to return the auto-generated ID and the value of one column. How would I go about doing this? Here's what I got so far:
delimiter //
drop procedure if exists insert_car//
create procedure insert_car(make VARCHAR(20), color VARCHAR(20))
begin
INSERT INTO table values (make,'2003', color);
SELECT LAST_INSERT_ID();
end//
delimiter ;
As LAST_INSERT_ID() is a normal function, you can just
SELECT LAST_INSERT_ID(), the_column FROM the_table LIMIT 1;
精彩评论