我有 1 条记录需要输入到表格中.在查询中执行此操作的最佳方法是什么?我应该做一个循环并在每次迭代中插入一条记录吗?或者有更好的方法吗?
I have 1-many number of records that need to be entered into a table. What is the best way to do this in a query? Should I just make a loop and insert one record per iteration? Or is there a better way?
来自 MySQL 手册
使用 VALUES 的 INSERT 语句语法可以插入多行.去做这包括多个列列表值,每个值都包含在括号并用逗号分隔.示例:
INSERT statements that use VALUES syntax can insert multiple rows. To do this, include multiple lists of column values, each enclosed within parentheses and separated by commas. Example:
INSERT INTO tbl_name (a,b,c) VALUES(1,2,3),(4,5,6),(7,8,9);
这篇关于如何在 MySQL 中进行批量插入的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持html5模板网!