<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 - 将新记录插入表中,主键自动递增

      PHP mySQL - Insert new record into table with auto-increment on primary key(PHP mySQL - 将新记录插入表中,主键自动递增)
      • <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 - 将新记录插入表中,主键自动递增的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                本站部分内容来源互联网,如果有图片或者内容侵犯了您的权益,请联系我们,我们会在确认后第一时间进行删除!

                相关文档推荐

                DeepL的翻译效果还是很强大的,如果我们要用php实现DeepL翻译调用,该怎么办呢?以下是代码示例,希望能够帮到需要的朋友。 在这里需要注意,这个DeepL的账户和api申请比较难,不支持中国大陆申请,需要拥有香港或者海外信用卡才行,没账号的话,目前某宝可以
                PHP通过phpspreadsheet导入Excel日期,导入系统后,全部变为了4开头的几位数字,这是为什么呢?原因很简单,将Excel的时间设置问文本,我们就能看到该日期本来的数值,上图对应的数值为: 要怎么解决呢?进行数据转换就行,这里可以封装方法,或者用第三方的
                mediatemple - can#39;t send email using codeigniter(mediatemple - 无法使用 codeigniter 发送电子邮件)
                Laravel Gmail Configuration Error(Laravel Gmail 配置错误)
                Problem with using PHPMailer for SMTP(将 PHPMailer 用于 SMTP 的问题)
                Issue on how to setup SMTP using PHPMailer in GoDaddy server(关于如何在 GoDaddy 服务器中使用 PHPMailer 设置 SMTP 的问题)
                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>
                            <tbody id='71niD'></tbody>
                          <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>