不正确的整数值:第 1 行的列 'id' 的 ''

2022-01-09 00:00:00 insert mysql

我正在尝试插入我的 mySQL 数据库.第一列是id"列,因为它是一个 auto_increment 字段,所以我将其留空.出于某种原因,我无法插入,并且收到下面提到的错误.感谢您对此提供的任何帮助.

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

我的查询

$insertQuery = "INSERT INTO workorders VALUES('', '$priority', '$requestType', '$purchaseOrder', '$nte', '$jobSiteNumber')";

推荐答案

这可能意味着你的 id 是一个 AUTO_INCREMENT 整数并且你正在尝试发送一个字符串.您应该指定一个列列表并从 INSERT 中省略它.

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 ($column1, $column2)

相关文章