I have an SQL database and would like to know how loops can be created in phpMyAdmin. I want to set the first column of my table as manual incremented. By this I mean I want to run a loop through all the rows which will set the integer value in the first column. It will set the numbers to: 1, 2, 3, 4, ... I don't want to set the column to
Maybe you want
truncate table. Who knows what exactly you want. As for gaps, they are your friends if they occur due to a looping mechanism due to a range allocation in that innodb engine. If the gaps occur otherwise (from deletes) that is good too for like a dozen reasons. The first one that comes to mind is Referential Integrity.
So, if you want it fresh with no data at the start, then truncate table clobbers everything and resets the AI value back to 1 for you. So the next time you insert, you are at 1. So, maybe because you say "overwrite anything if it is there" you mean you don't care about your prior data to begin with upon re-looping. Or, alternatively, maybe you mean for the prior data to be retained if not touched (you touch 1, 3, and 9).
Note that for parent tables in an FK relationship, the parent table cannot have
truncate table run against it. The equivalent to make it work would be would be:
delete from myTableA; alter table myTableA AUTO_INCREMENT=1;
The above with FK's would, of course, suggest that no child table rows would have the constraint violated by doing so.
Another unloved answer of mine about it is here. Shoot the messenger perhaps.