Access 2003: Auto Increment Field

M

MJMP

I am starting to learn about SQL and had a question about the INSERT INTO
statment.

For the sake of discussion, there is table titled SONG. It has three
attributes: SongID (primary key, increment), SongName, and AlbumID. Note
that the last SongID in the table is 12.

And if we were interested in writing an INSERT INTO statement that adds a
song called "Wanna Rock" with album ID of 4 into the table, we used:

INSERT INTO SONG
VALUES (13, 'Wanna Rock', 4)

Will that automatically insert 13 into the SongID field if the field is set
to increment? And what if there used to be a SongID of 14 and then a DELETE
query was run, if you where to run an INSERT query, will Access use 14 or
will it assign the next number of 15?

I hope that made sense!
 
L

Larry

You asked: Will that automatically insert 13 into the SongID field if
the field is set to increment? Yes, if by increment you mean the SongID
field is set to "auto number." You should be able to write your SQL
query as:

INSERT INTO SONG (SongName, AlbumID)
VALUES ('Wanna Rock', 4)

and let Access do the numbering for you.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top