| List: | MySQL and Java | « Previous MessageNext Message » | |
| From: | Tim Endres | Date: | July 16 2002 3:56am |
| Subject: | Re: returning identity field from a select statement | ||
| View as plain text | |||
You need to follow your insert with this:
SELECT LAST_INSERT_ID();
which will return a ResultSet with one row with one column
containing your ID. See 6.3.6.2 Miscellaneous Functions in
the documentation.
> MYSQL already has a function mysql_insert_id() for use in the C API but
> this does not work in java.
>
> Is there an equivalent function that I can use in my Java servlet to return
> the identity field after an insert ?
>
> I am using the version 1.4 JDK and the version 2.0.14 MM.MYSQL JDBC Driver
> for mySQL .
>
> I am using version 3.23.36 of mySQL.
>
> Can anyone help ?
| Thread | ||
|---|---|---|
| • returning identity field from a select statement | MHall | 16 Jul |
| • Re: returning identity field from a select statement | Jeff Kilbride | 16 Jul |
| • RE: returning identity field from a select statement | Jon Frisby | 19 Jul |
| • Re: returning identity field from a select statement | Mark Matthews | 19 Jul |
| • RE: returning identity field from a select statement | Jon Frisby | 19 Jul |
| • Re: returning identity field from a select statement | Tim Endres | 16 Jul |
| • Re: returning identity field from a select statement | Javier BolaƱos Molina(MCIC) | 16 Jul |
| • Re: returning identity field from a select statement | Andrew Houghton | 16 Jul |
| • Re: returning identity field from a select statement | Mark Matthews | 16 Jul |
| • Re: returning identity field from a select statement | Steve Forsyth | 16 Jul |
| • Re: returning identity field from a select statement | Steve Forsyth | 16 Jul |
| • Re: returning identity field from a select statement | Mark Matthews | 16 Jul |
