SA-MP Forums Archive
MySQL Insert ID - Printable Version

+- SA-MP Forums Archive (https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (https://sampforum.blast.hk/forumdisplay.php?fid=12)
+--- Thread: MySQL Insert ID (/showthread.php?tid=663834)



MySQL Insert ID - NoteND - 12.02.2019

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 !


Re: MySQL Insert ID - ComDuck - 12.02.2019

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?