删除查询 MySQL:列计数与第 1 行的值计数不匹配
问题描述:
我正在尝试从具有特定 ID 的表中删除所有行.我的查询是:
I am trying to delete all rows from a table with a particular id. my query is:
DELETE FROM table_name WHERE x_id='46';
返回的错误是:
#1136 - 列数与第 1 行的值数不匹配
我的表有一个复合主键 x_id
是主键中的列之一.
my table has a composite primary key x_id
is one of the columns in the primary key.
请帮忙!
答
该错误对于删除语句来说很奇怪.它很可能来自由于删除而执行的写入错误的触发器.
That error is strange for a delete statement. It is most likely coming from badly written trigger that is being executed as a result of the delete.
此错误很可能会在如下所示的插入语句中遇到:
This error would most likely be encountered on an insert statement such as the following:
insert into foo(bar, baz)
select bar, baz, foobar, 2
from myTable
注意 insert 语句如何指定 2 列,但提供 4 个值.
Note how the insert statement specifies 2 columns, but provides 4 values.