AdrenalineX Forums
General => Off-Topic => Topic started by: broodjehamburger on February 04, 2014, 12:16:47 pm
-
Hey guys,
I'm fooling around with mysql but can't figure out how to set the table id in a way that it's automatically +1'ed
for example i want to add an employee with this command:
insert into werknemers values(null, 'Jan', 'de Boer', '123', '440');
Now the 'null' should make the +1 happen automatically but it gives this error:
"#1048 - Column 'id' cannot be null"
the table ID is the primary key. Does it has to do something with that? I already tried changing the standard value to null but every time i save it it still says "as indicated" which is 0.
anyway i hope someone here can help me out :)
-
If id is auto_increment you can skip the id while inserting beacuse it's +1 each entry.
Try this:
INSERT INTO werknemers (column1, column2, column3, column4) VALUES( 'Jan', 'de Boer', '123', '440');
basically just skip the id because it's not something you can touch this way
-
Ah thanks man, it wasn't an auto_increment so i had to delete the column and alter the shit out it but everything worked out fine :)