mysql存储过程获得插入数据的自增长ID CREATE DEFINER=`root`@`localhost` PROCEDURE `chat_user_adduer`( in UN varchar(45), in Psw varchar(50), in NM varchar(45), in se tinyint, out Result int ) BEGIN
insert into t_b_chatuser(username,password,name,sex) values(UN,Psw,NM,se);
select Result=last_insert_id();
END 为什么Result的值是0呢?执行后确实插入数据了
------解决方案--------------------
SET Result=LAST_INSERT_ID(); SELECT Result;