使用一个查询MySQL插入多行 [英] Insert multiple rows with one query MySQL
本文介绍了使用一个查询MySQL插入多行的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我想编写脚本,并具有对多个插入查询的功能. 让我更好地解释一下.
I want to write script, with function to multiple insert query. let me explain this better.
我有一个以HTML格式输入的quantity
.
并且我有MySQL查询将registered user
插入表中.
所以我想让我的函数在数量"次内插入此查询.
I have one quantity
input in html form.
and I have MySQL query to insertregistered user
into the table.
so i want my function to insert this query for "quantity" times.
mysql_query("INSERT INTO `pxlot` (realname,email,address,phone,status,regtime,ip)
VALUES ('$realname','$email','$address','$phone','0','$dateTime','$ip')")
or die (mysql_error()); // Inserts the user.
例如要插入3次. 有什么建议?
To insert this for example 3 times. Any suggestions?
推荐答案
INSERT INTO table (a,b) VALUES (1,2), (2,3), (3,4);
http://dev.mysql.com/doc/refman/5.5/en/insert.html
这篇关于使用一个查询MySQL插入多行的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文