Reputation: 4222
For example,
there is a table articles
,it has these fields:
id
title
content
slug
id
field is auto-increment, the value starts from 1
.
Question:
I want to set slug
field to be auto-increment, and the value starts from 10000
,how to do it?
Upvotes: 0
Views: 506
Reputation: 8748
Why do you want 2 fields to be auto incremented? They are going to have the same values, even if one starts from 10000..
Example:
id | title | content | slug
---| ------|---------|------
1 | 10000
2 | 10001
3 | 10001
. | .
. | .
n | n + 10000 - 1
All you have to do is:
UPDATE articles SET slug = id + (10000 - 1) WHERE id = 'any id here..'
Upvotes: 1