in reply to inserting new data into table

Perhaps, as the others have said, you can choose "auto_increment" as the column type
to cause this behavior automatically. (For example, your SQL to insert a new entry would read something like "insert into TABLE values(NULL, myname)" and the db engine would increment the value in the first column.

Also, you could use "select MAX(ID) from TABLE", add one to this value, and manually increment like that.

What does this little button do . .<Click>; "USER HAS SIGNED OFF FOR THE DAY"

Replies are listed 'Best First'.
Re: Re: inserting new data into table
by salvadors (Pilgrim) on Jan 03, 2001 at 02:49 UTC

    Also, you could use "select MAX(ID) from TABLE", add one to this value, and manually increment like that.

    Of course, you'll only do this with a table lock won't you? (assuming you don't have transactions (MySQL etc), or have AUTO_COMMIT on).

    Otherwise imagine two INSERTs happening simultaneously ... someone else could quite happily come along and INSERT something else in between *your* SELECT and INSERT... leaving you with quite a nasty race condition.

    Tony

      Oh yeah - What Tony said ;-)

      What does this little button do . .<Click>; "USER HAS SIGNED OFF FOR THE DAY"