On 8/24/07, hardc0d3r <hardc0d3r@stripped> 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.