Taking X records, removing one record in the middle, then renumber...

From: Date: Mon, 06 Nov 2000 14:46:16 +0000
Subject: Taking X records, removing one record in the middle, then renumber...
Groups: php.general 
Request: Send a blank email to php-general+get-23889@lists.php.net to get a copy of this message
Hi, I'm having a problem where by I have a table containing the following data stored in a table in MySQL: |-------| | cid | --------- | 1 | | 2 | | 3 | | 4 | | 5 | --------- With PHP, I'm trying to work out some sort of algorithm that would, in a reasonably optimised fashion, enable me to do the following: Delete record 3 - obviously mysql_query("DELETE FROM table_name WHERE cid = 3") Then move anything after three up one spot, hence leaving the table with 1, 2, 3 & 4, so no holes in the numbering. Before anyone asks, it's not something that could be done by MySQL's auto_increment option :) Thanks :) Mark.

« previous php.general (#23889) next »