Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I insert an empty row, but have the autonumber update correctly?

Tags:

sql

mysql

I was hoping to be able to do something like

INSERT INTO `table`;

or maybe even a SET clause like

SET `primary_key` = null

where all the columns of the table aren't set (and are left to their default), with the exception of the autonumbered primary key which should be set.

Any suggestions?

like image 638
Shane Avatar asked Sep 02 '25 05:09

Shane


1 Answers

INSERT INTO `table` (`primary_key`) VALUES (NULL);
like image 155
Dan Simon Avatar answered Sep 04 '25 22:09

Dan Simon