【问题标题】:Insert value list does not match column list插入值列表与列列表不匹配
【发布时间】:2014-03-23 13:36:44
【问题描述】:

我有这样的疑问

 INSERT IGNORE INTO 2_1_accountsforpaidused (DebtorDebtAndPayment) VALUES (?,?);

还有这样的价值观

Array
(
[0] => 111
[1] => 222
)

想要在DebtorDebtAndPayment 列中插入VALUES (111,222)。在一行111,在下一行222

但是得到这样的错误

错误 stmt_for_insert_accountsforpaidused!:SQLSTATE[21S01]:插入值列表与列列表不匹配:1136 列计数与第 1 行的值计数不匹配

试图将查询更改为INSERT IGNORE INTO 2_1_accountsforpaidused (DebtorDebtAndPayment) VALUES ((?),(?)); 相同的结果

怎么了?

【问题讨论】:

    标签: mysql sql insert syntax-error sql-insert


    【解决方案1】:

    您告诉 mysql 您要插入一列,然后为它提供两个值。您需要:

    1. 将要插入的第二列添加到查询中

    2. 删除其中一个值

    3. 更改查询,使其对一个值进行两次插入

    数字 3 看起来像你想要的:

    INSERT IGNORE INTO 2_1_accountsforpaidused (DebtorDebtAndPayment) VALUES (?),(?);
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2013-01-23
      • 1970-01-01
      • 1970-01-01
      • 2020-06-25
      • 1970-01-01
      • 2012-09-19
      • 2020-01-12
      • 1970-01-01
      相关资源
      最近更新 更多