On 8/14/06, William DeMasi <[EMAIL PROTECTED]> wrote:
Does anyone have any ideas of how I can select the max value and insert the
next highest value?

I want something that would do something like this:

Insert into table1 (select max(field1)+1 from table1);

This obviously doesn't work.

I know if the table was set to auto-increment it wouldn't be an issue, but I
am not able to change its schema.

Thank you.

- William


with a store procedure, something like:

CREATE PROCEDURE InsertNext ()

BEGIN
 DECLARE myNext INT;

 DECLARE cur_for_next CURSOR FOR
 select coalesce( max(field1),0 ) +1 from table1;

 OPEN cur_espacio_tanque;
  FETCH cur_for_next INTO myNext;
 CLOSE cur_espacio_tanque;

 INSERT INTO table1 values ( myNext );
END;

y you call it

call InsertNext ();

may be can works

--
http://www.obed.org.mx ---> blog

--
MySQL General Mailing List
For list archives: http://lists.mysql.com/mysql
To unsubscribe:    http://lists.mysql.com/[EMAIL PROTECTED]

Reply via email to