This week's book giveaway is in the Clojure forum.
We're giving away four copies of Clojure in Action and have Amit Rathore and Francis Avila on-line!
See this thread for details.
Win a copy of Clojure in Action this week in the Clojure forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

sql auto increment question

 
Aris Doxakis
Ranch Hand
Posts: 136
Android Java Windows
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hello,

im using sql 4.0 and i have created a table that has a field book_id which is a primary key and,integer with auto increment.How can i insert a new book?tried but still cant figure how to make auto increment work.

thnx in advance!!
 
Naseem Khan
Ranch Hand
Posts: 809
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You don't need to insert id, insert rest of the details.
 
Paul Clapham
Sheriff
Pie
Posts: 20187
26
MySQL Database
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
It would be easier to advise if we knew what you had already tried. But the general idea is to leave the book-id column out of your INSERT statement and let the database generate the key value.
 
Aris Doxakis
Ranch Hand
Posts: 136
Android Java Windows
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
so for me to understand a simple example:

insert into books(every field exept book_id) values(every value exept book_id)

is this right??
thnx alot!!
 
Jeanne Boyarsky
author & internet detective
Marshal
Posts: 33694
316
Eclipse IDE Java VI Editor
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Aris,
Yes, that is correct. The database takes care of the one field you left out.
 
I agree. Here's the link: http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic