corsasport.co.uk
 

Corsa Sport » Message Board » Off Day » Geek Day » mySQL help


New Topic

New Poll
  Subscribe | Add to Favourites

You are not logged in and may not post or reply to messages. Please log in or create a new account or mail us about fixing an existing one - register@corsasport.co.uk

There are also many more features available when you are logged in such as private messages, buddy list, location services, post search and more.


Author mySQL help
drax
Member

Registered: 5th Feb 05
Location: Sittingbourne, Kent
User status: Offline
10th Apr 07 at 11:42   View User's Profile U2U Member Reply With Quote

After removing rows from a table, where an auto increment is placed on an ID field, is there anyway of having the auto increment continue from the last number, or to reorder them all?

So it doesnt leave it as

1
2
3
10


Ian
Site Administrator

Avatar

Registered: 28th Aug 99
Location: Liverpool
User status: Offline
10th Apr 07 at 13:04   View Garage View User's Profile U2U Member Reply With Quote

There are ways of doing what you want but I personally wouldn't. That value is unique to the record, regardless of whether the record still exists. If you go renumbering stuff then you run the risk of duplicate key errors.

Could you not just increment the count in the application somewhere? ie. in PHP just throw a quick

$count++;

inside your loop and display that?

Alternatively if you want to renumber and are sure you'll never be deleting records again, export the table as CSV, open in Excel, blank the first column, save as CSV and re-import. The auto_increment field will take care of the blank field an increment as it should.
drax
Member

Registered: 5th Feb 05
Location: Sittingbourne, Kent
User status: Offline
10th Apr 07 at 13:31   View User's Profile U2U Member Reply With Quote

Cheers Ian, i was just curious as to keep things tidy, but function over form.

working on abit of a heavy project at the moment, really trying to get back on foot with php only really touched basics with it about 6 years ago, so it is abit mind boggling at the moment..


 
New Topic

New Poll

  Related Threads Author Forum Replies Views Last Post
Linking .jsp pages to a MySQL database chris_lee100 Geek Day 7 1382
1st Feb 04 at 14:23
by Ian
 
forum hacking - SQL's Drew Geek Day 15 1698
9th Sep 04 at 23:50
by Ian
 
Server Help Jodi_the_g Geek Day 7 1435
19th Jan 06 at 15:18
by Jodi_the_g
 
My SQL-Nearly there! Tom J Geek Day 31 3137
25th Dec 06 at 23:32
by Ian
 

Corsa Sport » Message Board » Off Day » Geek Day » mySQL help 29 database queries in 0.0113361 seconds