Neohapsis is currently accepting applications for employment. For more information, please visit our website www.neohapsis.com or email firstname.lastname@example.org
From: Michael Dykman (mdykmangmail.com)
Date: Fri Aug 24 2007 - 10:36:35 CDT
On 8/24/07, hardc0d3r <hardc0d3rgmail.com> wrote:
> yup, that's it.. thanks for the reply..
More typically, you would use the last_insert_id() function which will
return the value of the most recently created auto-increment key...
CREATE TABLE mytable (
id int auto_increment primary key,
INSERT INTO mytable (foo) VALUES('a');
SELECT LAST_INSERT() AS newkey;
calculating the max key + 1 , as it has been noted, must be done
transactionally and will therefore require a transactional table
type... The catch is that, unlike MyISAM, Innodb does not maintain
column meta information like min, max, sum so this approach will get
more expensive with each subsequent call.
- michael dykman
- All models are wrong. Some models are useful.
MySQL General Mailing List
For list archives: http://lists.mysql.com/mysql