Go to the first, previous, next, last section, table of contents.


How to get the value of a AUTO_INCREMENT column in ODBC

A common problem is how to get the value of an automatically-generated id from an INSERT. With ODBC you can do something like this:

INSERT INTO foo (auto,text) VALUES(NULL,'text')
select LAST_INSERT_ID()

or if you are just going to insert in into another table:

INSERT INTO foo (auto,text) VALUES(NULL,'text')
INSERT INTO foo2 (id,text) VALUES(LAST_INSERT_ID(),'text')


Go to the first, previous, next, last section, table of contents.