1
votes

I'm creating a database using mysql and im trying to insert values into it but its not working. Can someone show me the error of my ways, its probably a really small common error I'm making.

create table cars (
Car_VIN CHAR(17),
Car_model CHAR(20),
Car_year int,
Car_make char(20),
Current_Mileage int,
Car_price int,
Car_bodytype char(20),
Car_color char(20),
Car_trim char(20),
Car_additionaloptions char(200),
primary key (Car_VIN));

insert into cars values ('JF1SF65611H734114','Model 3',2020,'Tesla',37990,'Sedan','White','Base','None');

Error: ERROR 1136 (21S01): Column count doesn't match value count at row 1

1
The error message seems self-explanatory. Further, while memory is cheap, those CHARs would benefit from being VARCHARsStrawberry
you have missed giving value for a column, you tables has 10 columns while the values which you have given are only 9SQL_New_bee
Always list the columns you are trying to insert. char() is not a cgood choice for a data type.Gordon Linoff

1 Answers

3
votes

You've missed the Car_price value.

I've input 2000000 for your reference:

create table cars (
       Car_VIN CHAR(17),
       Car_model CHAR(20),
       Car_year int,
       Car_make char(20),
       Current_Mileage int,
       Car_price int,
       Car_bodytype char(20),
       Car_color char(20),
       Car_trim char(20),
       Car_additionaloptions char(200),
       primary key (Car_VIN));
insert into cars values (
'JF1SF65611H734114','Model 3',2020,'Tesla',37990,
2000000,'Sedan','White','Base','None');