Jump to content
Sign in to follow this  
Aviram

AUTO INCREMENT statement in SQL

Recommended Posts

Hi .
I'm having trouble with the AUTO INCREMENT statement in SQL.
I've built the table :

CREATE TABLE tenants(
    apartment_number_first_floor INT AUTO_INCREMENT,
    family_name VARCHAR (12) DEFAULT NULL,
    sur_name VARCHAR (8) DEFAULT NULL,
    telephone_number INT(3) NOT NULL,
     PRIMARY KEY (apartment_number_first_floor)
    );

when inserting a row:
        INSERT INTO tenants VALUES(' ',' ');
The IDE doesn't accept the column count:
        ER_WRONG_VALUE_COUNT_ON_ROW: Column count doesn't match value count at row 1

So i tried filling the rows just to check if the IDE will run  the statement
       INSERT INTO tenants VALUES(103,'שקלובין','מרתה',203);
 but the IDE refuses to increment 

 

Any ideas?
Thanks

Share this post


Link to post
Share on other sites

You need to pass null for that column if you want it to auto-increment.  Or, better yet, list the columns you are inserting and leave out the auto-increment column completely.

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
Sign in to follow this  

×
×
  • Create New...