PDA

View Full Version : Getting Value filled automatically in an autonumeric column?


piz
05-29-2003, 12:08 PM
Hi,

I am searching for a way to get the value of an autonumeric column filled in by an INSERT-Statement.

In the INSERT-Statement I don't fill anything into the autonumeric column.

If my table had this form: (id is autonumeric)

id | field1 | field2 | etc

I use this Statement:

INSERT INTO table (field1, field2, ...) VALUES ("...", "...", ...)

Is there any way to get - just after executing this MySQL Query - the value which was filled in the column [id], without having to execute another query getting the last record filled in or the record with the hightest [id]?

Thx.
piz

Galdo
05-29-2003, 12:49 PM
Have a look here (http://www.php.net/manual/en/function.mysql-insert-id.php).

(Presuming you are using PHP that is).

Spookster
05-29-2003, 04:11 PM
Interesting. :thumbsup: Didn't know about that one.

piz
05-29-2003, 05:29 PM
Thx very much!
That's it!
:-)