| List: | General Discussion | « Previous MessageNext Message » | |
| From: | Dan Nelson | Date: | September 19 2002 5:59pm |
| Subject: | Re: Auto Increment ID of Inserted Row | ||
| View as plain text | |||
In the last episode (Sep 19), Steven Kreuzer said: > >What is the SQL to get the created AutoInc ID from a row that I have > >just inserted? > > SELECT MAX(id_field) FROM table Nope. If someone else inserted a record between the time you inserted yours and the time you run that select, your answer will be wrong. Use LAST_INSERT_ID(), or whatever construct your language provides for retrieving it without doing another query. -- Dan Nelson dnelson@stripped
| Thread | ||
|---|---|---|
| • Auto Increment ID of Inserted Row | Tim Davis | 19 Sep |
| • Re: Auto Increment ID of Inserted Row | Paul DuBois | 19 Sep |
| • Re: Auto Increment ID of Inserted Row | Steven Kreuzer | 19 Sep |
| • Re: Auto Increment ID of Inserted Row | Paul DuBois | 19 Sep |
| • Re: Auto Increment ID of Inserted Row | Rodney Broom | 19 Sep |
| • Re: Auto Increment ID of Inserted Row | Dan Nelson | 19 Sep |
| • RE: Auto Increment ID of Inserted Row | Michael Tam | 19 Sep |
