How can I skip a column when inserting a new row into a table without knowing neither the names nor the amount of columns in my table?
Using INSERT (col1, col2) VALUES (1, 2)
is not an option, because I can not know the amount of columns during runtime. It's all calculated from user input.
Thus, I need to skip the first column (id
, PRIMARY KEY auto_increment) when inserting.
You can insert without giving column names, but you had to give some values for all columns.
Try inserting 0 as the first value. If the column is auto-incremented it should work.
From MySQL reference: "No value was specified for the AUTO_INCREMENT column, so MySQL assigned sequence numbers automatically. You can also explicitly assign NULL or 0 to the column to generate sequence numbers. " http://dev.mysql.com/doc/refman/5.5/en/example-auto-increment.html