Search code examples
mysqlinsert

Incorrect integer value: '' for column 'id' at row 1


I am trying to insert into my mySQL database. The first column is the 'id' column, since its an auto_increment field, I left it blank. For some reason, I am unable to insert and I am getting the error mentioned below. I appreciate any help with this.

I am getting the following error while trying to insert:

Incorrect integer value: '' for column 'id' at row 1

my query

INSERT INTO workorders VALUES('', ?, ?, ?, ?, ?)

Solution

  • That probably means that your id is an AUTO_INCREMENT integer and you're trying to send a string. You should specify a column list and omit it from your INSERT.

    INSERT INTO workorders (column1, column2) VALUES (?, ?)