Aviram Posted June 6, 2019 Share Posted June 6, 2019 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 Link to comment Share on other sites More sharing options...
justsomeguy Posted June 7, 2019 Share Posted June 7, 2019 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. Link to comment Share on other sites More sharing options...
Makwana Prahlad Posted March 12, 2020 Share Posted March 12, 2020 Hello, @Aviram Please try this query, To AUTO INCREMENT statement in SQL: CREATE TABLE tenants( apartment_number_first_floor INT IDENTITY(1,1) PRIMARY KEY, family_name VARCHAR (12) DEFAULT NULL, sur_name VARCHAR (8) DEFAULT NULL, telephone_number INT(3) NOT NULL, ); I hope above query will be useful for you. Thank you. Link to comment Share on other sites More sharing options...
Ingolme Posted March 12, 2020 Share Posted March 12, 2020 Please do not reply to old topics. Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now