Jump to content

INSERT IN ORDER


mc_keny

Recommended Posts

hey ppl ok here is the thing i creat a data base with these field id,name,pass and register form where i insert the specify user name and pass mysql_query("INSERT INTO mc_users (name,pass) VALUES ('mc_keny','$pass')");[/code]i want mc_keny to have id 1 but instead it got id 3 any can help me pls

Link to comment
Share on other sites

Well, the table is created already. You can go modify the table with PHPmyAdmin if you want, and if not then drop that table and create a new one. If AUTO_INCREMENT isn't activated you'll need to go increasing the ids manually.What I'd do in that case is check the highest existant ID in the table and sum 1 to it and put it in the new register.

Link to comment
Share on other sites

It's not random, it's the next number available. If you insert a new row with an ID of 4 that means that it already used IDs 1, 2, and 3 for other rows. Even if you delete a row it will not reset the autoincrement value. So you can insert 2 rows, then delete them, then insert another and the new row will have an ID of 3. You can delete that one and add a new one and, even though it's the only one there, it has an ID of 4. It's not random, it's sequential. If you really want to reset the autoincrement value to something else (which is never necessary, and may even be a bad idea), you can use an ALTER TABLE statement.http://dev.mysql.com/doc/refman/5.0/en/alter-table.html

To change the value of the AUTO_INCREMENT counter to be used for new rows, do this: ALTER TABLE t2 AUTO_INCREMENT = value;
Link to comment
Share on other sites

You can also query "TRUNCATE mc_users" that will remove all records and reset the auto_increment counter to 1.

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...