General > Off-Topic
mysql
(1/1)
broodjehamburger:
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 :)
[MAF]Cromiell:
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
broodjehamburger:
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 :)
Navigation
[0] Message Index
Go to full version