PHP MYSQL - 插入而不使用列名但使用自动增量字段 [英] PHP MYSQL - Insert into without using column names but with autoincrement field

查看:33
本文介绍了PHP MYSQL - 插入而不使用列名但使用自动增量字段的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要在 MySQL 表中插入一个包含 32 个字段的长行.

I need to insert a long row with 32 fields into a MySQL table.

我想做这样的事情:

$sql="insert into tblname values (... 32 fields ...)";

显然,如果字段与 MySQL 表字段的顺序相同,它就可以正常工作.但是,我的表有一个自动递增 ID,因为它是第一个字段.

Obviously it works fine if the fields are in the same order as the MySQL table fields. But, my table has an auto-increment id as it's first field.

我想要的是填写所有表名,但第一个 (id) 除外.

What I want is to fill in all table names but the first (id) one.

建议?

推荐答案

只需使用 NULL 作为您的第一个值,autoincrement 字段仍将按预期工作:

Just use NULL as your first value, the autoincrement field will still work as expected:

INSERT INTO tblname VALUES (NULL, ... 32 Fields ... )

这篇关于PHP MYSQL - 插入而不使用列名但使用自动增量字段的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆