mysql中如何用mysql_query()一次执行多个insert语句?

不支持,必须一次一次执行

               $formatid = mysql_insert_id();

                $count = count($_POST['FieldSeq']);

                for($tmp=0;$tmp<$count;$tmp++)
                {
                    $subSQL= “INSERT INTO tblAddrFormatDtl SET “;
                    $subSQL.=”FormatID=”.$formatid.”,”;
                    $subSQL.=”FieldSeq=”.$_POST['FieldSeq'][$tmp].”,”;
                    $subSQL.=”FieldName=’”.$_POST['FieldName'][$tmp].”‘,”;
                    $subSQL.=”OutputSeq=”.$_POST['OutputSeq'][$tmp].”,”;
                    $subSQL.=”ParentField=’”.$_POST['ParentField'][$tmp].”‘,”;;
                    $subSQL.=”ListCode=’”.$_POST['ListCode'][$tmp].”‘,”;
                    $subSQL.=”EntryFlag=”.$_POST['EntryFlag'][$tmp].”,”;
                    $subSQL.=”NewLine=”.$_POST['NewLine'][$tmp].”;”;
                    mysql_query($subSQL);
                }

觉得文章有用?立即: 和朋友一起 共学习 共进步!

猜您喜欢

3 thoughts on “mysql中如何用mysql_query()一次执行多个insert语句?

  1. insert 不是支持一个insert 插入多条记录么?把语法构建成

    INSERT tbl_name (col_name,…)
    VALUES ( value,…),(…),…

    就好了。

发表评论

电子邮件地址不会被公开。 必填项已用 * 标注

*

您可以使用这些 HTML 标签和属性: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>