如何从一定数量/偏移量开始自动增加? [英] How to AUTOINCREMENT starting from a certain number/offset?

查看:99
本文介绍了如何从一定数量/偏移量开始自动增加?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在运行fgetcsv查询,以将CSV中的一堆数据导入WordPress.

I am running an fgetcsv query to import a bunch of data from a CSV into WordPress.

我想知道如何从某个数字开始自动递增,例如从1000开始.

I am wondering how I can start an auto increment from a certain number, for example, from 1000 onwards.

$import1="INSERT into wp_postmeta (meta_id,post_id,meta_key,meta_value) values(',',',','first_name','$data[1]')";

这是代码示例. meta_id应该使用正常的自动增量,但是我要从某个数字开始的post_id.

This is an example of the code. the meta_id should use a normal auto increment, but the post_id I want to start from a certain number.

我该怎么做?

推荐答案

要设置自动增量字段的起始值,可以使用alter table

To set the starting value for an auto increment field, you can use alter table

ALTER TABLE wp_postmeta AUTO_INCREMENT = 1000;

据我所知,在mysql的同一张表上不可能有两个自动递增字段,因此您必须自己进行编程(例如,使用触发器)

As far as I know, it is not possible to have two auto incrementing fields on the same table in mysql, so you have to do it progamatically yourself (eg with a trigger)

这篇关于如何从一定数量/偏移量开始自动增加?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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