Jump to content

ALTER TABLE, ORDER BY,.. keep all columns intact except 1...


lordvader

Recommended Posts

Let's say:

Primary Key | UID's | Additional Info 1 |  Additional Info 2

1 | 5 | foo5 | bar5

2 | 3 | foo3 | bar3

3 | 4 | foo4 | bar4

 

Primary Key is autoincrement

UID is non-sequential, but unique numbers

 

How do I sort this table so that UID is sequential again (lowest to highest) while keeping their associations with additional info 1,2, and keeping the primary keys where they are?

1 | 3 | foo3 | bar3

2 | 4 | foo4 | bar4

3 | 5 | foo5 | bar5

 

Thanks

I'm still learning mysql and the hard part is wrapping my head around all the nuances - every practice problem is so specific to the given example story that if I want to try variations, I'm lost because I don't know mysql's limitations and abilities.

Is it a problem with mysql or just sql in general. It would seem to me that you are used to ISAM type databases or flat files and are trying to absorb how SQL itself works. If so, try a tutorial on SQL, it should help. Especially design.

 

Manuals usually just tell you how to use the features, not why you want to.

I'm still learning mysql and the hard part is wrapping my head around all the nuances - every practice problem is so specific to the given example story that if I want to try variations, I'm lost because I don't know mysql's limitations and abilities.

Then explain what you actually want to do.

Archived

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

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.