LAST_INSERT_ID() MySQL

后端 未结 11 2279
花落未央
花落未央 2020-11-22 10:56

I have a MySQL question that I think must be quite easy. I need to return the LAST INSERTED ID from table1 when I run the following MySql query:

INSERT INTO          


        
11条回答
  •  死守一世寂寞
    2020-11-22 11:18

    For last and second last:

    INSERT INTO `t_parent_user`(`u_id`, `p_id`) VALUES ((SELECT MAX(u_id-1) FROM user) ,(SELECT MAX(u_id) FROM user  ) );
    

提交回复
热议问题