insert a row with next available id

I

ivan.svaljek

INSERT INTO table (idn,idkup) VALUES (SELECT MAX(idn)+1 FROM table, ?)

does not work.

nor does:

INSERT INTO table (idn,idkup) SELECT (SELECT MAX(idn)+1 FROM table, ?)
as idn, ? as idkup
 
M

mscertified

Use an autonumber column is the best solution
If you cant, do a DLOOKUP to get the max key so far, then a serparate INSERT
command. But this is error-prone because an intervening insert could be done
between the 2 statements executing.

-Dorian
 
Top