Recently, a primary key in my database got messed up somehow. I ran a script to reorder the users, but now every user has the wrong private messages.

--
-- Table structure for table `fusion_messages`
--

CREATE TABLE `fusion_messages` (
  `message_id` mediumint(8) unsigned NOT NULL auto_increment,
  `message_to` mediumint(8) unsigned default '0',
  `message_from` mediumint(8) unsigned default '0',
  `message_subject` varchar(100) NOT NULL default '',
  `message_message` text NOT NULL,
  `message_smileys` char(1) NOT NULL default '',
  `message_read` tinyint(1) unsigned NOT NULL default '0',
  `message_datestamp` int(10) unsigned NOT NULL default '0',
  `message_folder` tinyint(1) unsigned NOT NULL default '0',
  PRIMARY KEY  (`message_id`),
  KEY `message_datestamp` (`message_datestamp`)
) ENGINE=MyISAM  DEFAULT CHARSET=latin1 AUTO_INCREMENT=5618 ;

There's the table structure. As you see, there are message_from and message_to fields. I want the users to be reordered so that they go to the correct user. All I want is the numbers to be in sequential order.
For example, the users used to be
1,3,5,12,13,14,15,16,17
but I made them
1,2,3,4,5,6,7,8,9
and now I want to do it with this table.

EDIT: The corresponding numbers are:
1
3-104
106-108
110-113
118-120
122
123
127-136
138
1339-1389

and

sequential order.

You just have to tell me the process for converting one of them; I'll do the rest.
Like converting 3 to 2 in each one.

Please help,
grr

i don't have a clear idea of what you are wanting

the message_from field has a 3 and it needs to be a 104?

And just as good practice, a database is there for the organization, it doesn't need to be in sequential order.

It may look prettier to you if it is, but just add an order by user_id or whatever it may be to your query, trying to update id's all over the place is a pain in the a@@ if you don't have the correct set of foreign keys in place

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.