使用MySQL批量插入数据库表数据
我正在使用 MySQL 将多个条目上传到我们数据库的表中。但是,以下命令不起作用并引发此错误“#1136 - 列计数与第 1 行的值计数不匹配”...这很奇怪,因为下面包含 4 列:
(我刚刚在此处包含了两个结果作为数据示例)
INSERT INTO state (state_id,country_id,state_name,active) VALUES (152,153),(5),(Test1,Test2),(1)
这应该形成多行,最终如下所示:
state_id |国家/地区 ID |州名 |积极的 152 5 测试 1 1 153 5 Test 2 1
(看起来像编辑中的表格...但此处未呈现,抱歉!)
I'm uploading multiple entries into a table in our database using MySQL. However, the following command does not work and throws up this error "#1136 - Column count doesn't match value count at row 1"... which is odd as there are 4 columns as included below:
(I've just included two of the results here as an example of the data)
INSERT INTO state (state_id,country_id,state_name,active) VALUES (152,153),(5),(Test1,Test2),(1)
This should form multiple rows and eventually look like this:
state_id | country_id | state_name | active
152 5 Test 1 1
153 5 Test 2 1
(that looks like a table in the edit... but not rendered on here, sorry!)
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
如果定义了 4 列,则还必须在 VALUES 之后放置 4 个值的组。
After VALUES you also have to put groups of 4 values if you defined 4 columns.
试试这个:
Try this:
要插入多行,您需要为每行提供正确数量的值。
语法是这样的:您指定一行接着另一行,而不是列:
To insert multiple rows, you need to supply the correct number of values for each row.
The syntax is such that you specify one row after the other, not columns: