MySQL Insert ID
#1

Hey!

I'm just wondering.. How do you check when Auto-Increment "ID" in mysql database reaches for example 15..
and how to set it so it will start from 0 again when next executed. Thanks in advance !
Reply
#2

https://www.bram.us/2008/07/30/mysql...fromfor-table/

^ shows what your next AUTO_INCREMENT value will be. Store that in a variable, and write a condition to check the value against your limit.

Besides, AUTO_INCREMENT starts from 1 and not 0 by default. To reset the AUTO_INCREMENT, perform an ALTER request for the table in question:

Код:
ALTER TABLE table_name_here AUTO_INCREMENT = 1
Even if you change the 1 to a 0, the AUTO_INCREMENT will still be set to 1 unless you modified your server settings to omit the above condition.

EDIT: Why are you doing this, by the way? Can you describe more of your situation?
Reply


Forum Jump:


Users browsing this thread: 2 Guest(s)