<legend id='szIQM'><style id='szIQM'><dir id='szIQM'><q id='szIQM'></q></dir></style></legend>

    <i id='szIQM'><tr id='szIQM'><dt id='szIQM'><q id='szIQM'><span id='szIQM'><b id='szIQM'><form id='szIQM'><ins id='szIQM'></ins><ul id='szIQM'></ul><sub id='szIQM'></sub></form><legend id='szIQM'></legend><bdo id='szIQM'><pre id='szIQM'><center id='szIQM'></center></pre></bdo></b><th id='szIQM'></th></span></q></dt></tr></i><div id='szIQM'><tfoot id='szIQM'></tfoot><dl id='szIQM'><fieldset id='szIQM'></fieldset></dl></div>

    • <bdo id='szIQM'></bdo><ul id='szIQM'></ul>

    <small id='szIQM'></small><noframes id='szIQM'>

    <tfoot id='szIQM'></tfoot>

      PHP mySQL - 将新记录插入表中,主键自动递增

      时间:2023-10-30
      • <bdo id='FhAMr'></bdo><ul id='FhAMr'></ul>
        <legend id='FhAMr'><style id='FhAMr'><dir id='FhAMr'><q id='FhAMr'></q></dir></style></legend>

        <tfoot id='FhAMr'></tfoot>

            <i id='FhAMr'><tr id='FhAMr'><dt id='FhAMr'><q id='FhAMr'><span id='FhAMr'><b id='FhAMr'><form id='FhAMr'><ins id='FhAMr'></ins><ul id='FhAMr'></ul><sub id='FhAMr'></sub></form><legend id='FhAMr'></legend><bdo id='FhAMr'><pre id='FhAMr'><center id='FhAMr'></center></pre></bdo></b><th id='FhAMr'></th></span></q></dt></tr></i><div id='FhAMr'><tfoot id='FhAMr'></tfoot><dl id='FhAMr'><fieldset id='FhAMr'></fieldset></dl></div>

              <small id='FhAMr'></small><noframes id='FhAMr'>

                <tbody id='FhAMr'></tbody>

              1. 本文介绍了PHP mySQL - 将新记录插入表中,主键自动递增的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                问题描述

                想知道是否有一个速记版本可以将新记录插入到启用了主键的表中?(即不必在查询中包含键列)假设键列称为 ID,其他列是 Fname、Lname 和网站

                Wondering if there is a shorthand version to insert a new record into a table that has the primary key enabled? (i.e. not having to include the key column in the query) Lets say the key column is called ID, and the other columns are Fname, Lname, and Website

                $query = "INSERT INTO myTable VALUES ('Fname', 'Lname', 'Website')";
                

                推荐答案

                使用 DEFAULT 关键字:

                Use the DEFAULT keyword:

                $query = "INSERT INTO myTable VALUES (DEFAULT,'Fname', 'Lname', 'Website')";
                

                此外,您可以指定列,(这是更好的做法):

                Also, you can specify the columns, (which is better practice):

                $query = "INSERT INTO myTable
                          (fname, lname, website)
                          VALUES
                          ('fname', 'lname', 'website')";
                

                参考:

                • http://dev.mysql.com/doc/refman/5.6/en/data-type-defaults.html

                这篇关于PHP mySQL - 将新记录插入表中,主键自动递增的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                上一篇:php在mysql数据库中运行一次并插入两次 下一篇:如何使用 PHP 附加到 XML 文件,最好使用 SimpleXML

                相关文章

                1. <small id='71niD'></small><noframes id='71niD'>

                  • <bdo id='71niD'></bdo><ul id='71niD'></ul>
                  <legend id='71niD'><style id='71niD'><dir id='71niD'><q id='71niD'></q></dir></style></legend>
                    <i id='71niD'><tr id='71niD'><dt id='71niD'><q id='71niD'><span id='71niD'><b id='71niD'><form id='71niD'><ins id='71niD'></ins><ul id='71niD'></ul><sub id='71niD'></sub></form><legend id='71niD'></legend><bdo id='71niD'><pre id='71niD'><center id='71niD'></center></pre></bdo></b><th id='71niD'></th></span></q></dt></tr></i><div id='71niD'><tfoot id='71niD'></tfoot><dl id='71niD'><fieldset id='71niD'></fieldset></dl></div>
                  1. <tfoot id='71niD'></tfoot>