0

i already have the id field which is auto increment primary key. I have another field that i want to be auto increment/autonumber but phpadmin/mysql doesn't allow? how else do i have a field with an autonumber?

4
Contributors
4
Replies
5
Views
7 Years
Discussion Span
Last Post by mschroeder
0

i just need a field that adds 1 to the current integer.... auto increment does that perfectly, but it only allows 1?

0

The other solution would be to calculate the value using the auto incremented value i.e if your value started at 5 and the id was 7 instead of starting a count wasting db space just get the id and 5.

$new_num = $row + 5;

0

You can not have more than one auto-increment column in the same table in MySQL.

You could however do something like:

/*
  Table
  +-----------+------------+
  | RowId (AI)| RowCount   |
  +-----------+------------+
  | 1         | 37         |
  +-----------+------------+
  | 2         | 51         |
  +-----------+------------+
  | 3         | 26         |
  +-----------+------------+
*/

UPDATE Table SET RowCount = RowCount + 1 WHERE RowId = 1

That query would increment your rowcount by 1 each run.

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.