Whats the standard way of getting the last insert id?
What's the sql standard to get the last inserted id? If there is such a thing. mysql: LAST_INSERT_ID() postgresql: ... RETURNING f_id mssql: SCOPE_IDENTITY() ... more examples here ... I mean, all databases have different implementations for that, there isn't a standard for such a common task? RichardTheKiwi See this answer Retrieve inserted row ID in SQL In short, there is no cross database way to do this, except MAX(ID) - but that is not a guaranteed result and has many many pitfalls, e.g. other inserts can come between last insert and max query cannot be used with high transaction tables