本文介紹了如何在 MySQL 中進(jìn)行批量插入的處理方法,對(duì)大家解決問題具有一定的參考價(jià)值,需要的朋友們下面隨著小編來(lái)一起學(xué)習(xí)吧!
問題描述
我有 1 條記錄需要輸入到表格中.在查詢中執(zhí)行此操作的最佳方法是什么?我應(yīng)該做一個(gè)循環(huán)并在每次迭代中插入一條記錄嗎?或者有更好的方法嗎?
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?
推薦答案
來(lái)自 MySQL 手冊(cè)
使用 VALUES 的 INSERT 語(yǔ)句語(yǔ)法可以插入多行.去做這包括多個(gè)列列表值,每個(gè)值都包含在括號(hào)并用逗號(hào)分隔.示例:
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);
這篇關(guān)于如何在 MySQL 中進(jìn)行批量插入的文章就介紹到這了,希望我們推薦的答案對(duì)大家有所幫助,也希望大家多多支持html5模板網(wǎng)!
【網(wǎng)站聲明】本站部分內(nèi)容來(lái)源于互聯(lián)網(wǎng),旨在幫助大家更快的解決問題,如果有圖片或者內(nèi)容侵犯了您的權(quán)益,請(qǐng)聯(lián)系我們刪除處理,感謝您的支持!