gpt4 book ai didi

php - 插入时无效的mysql查询

转载 作者:IT王子 更新时间:2023-10-28 23:49:11 24 4
gpt4 key购买 nike

我必须将错误的代码转换为更好的解决方案,以计算我们网站的计数。我有一张统计次数的表

当前表:

CREATE TABLE `hits_2011_12_5` (
`count` int(11) DEFAULT NULL
) ENGINE=MyISAM DEFAULT CHARSET=latin1;

现在我想慢慢地将新代码迁移到旧代码,但新代码出现此错误:

ana@localhost:test> insert into hits_2011_12_5 values (1,2,3,4,5);
ERROR 1136 (21S01): Column count doesn't match value count at row 1

可能是什么问题?

最佳答案

使用这个:

ana@localhost:test> insert into hits_2011_12_5 values (1),(2),(3),(4),(5);
Query OK, 5 rows affected (0.00 sec)
Records: 5 Duplicates: 0 Warnings: 0

您尝试的查询需要 5 列,而不是插入 5 行。

关于php - 插入时无效的mysql查询,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/8385111/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com