SQL - Inserting a row and returning primary key

前端 未结 8 1161
南笙
南笙 2020-12-01 18:07

I have a little witty problem. Say, I inserted a row with some data in a table where a primary key is present. How would one \"SELECT\" the primary key of the row one just i

8条回答
  •  庸人自扰
    2020-12-01 18:11

    select MAX(id_column) from table
    

    That, in theory, should return you that last inserted id. If it's a busy database with many inserts going on it may not get the one you just did but another.

    Anyhow, an alternative to other methods.

提交回复
热议问题