nazca Posted July 13, 2006 Share Posted July 13, 2006 I have entered restaurants into my database by city to speed the process up, but when I find another restaurant later and put it with the same cityit comes later and not in-order by name. Since i cannot order by name due to complexities, how can I re-assign the id numbers in my database so thatthe restaurants are displayed alphabetically correctly within each city. I can do a script each time for each city does not bother me. I want to keep my data of course. Hope you can help and thanks. Quote Link to comment Share on other sites More sharing options...
cmgmyr Posted July 13, 2006 Share Posted July 13, 2006 one thing that you can do is change the id's to show alfa order. (change the first one that is supposed to be the first alphabetically to 1, the second to 2)It might take a while, I would try re-thinking your database.-Chris Quote Link to comment Share on other sites More sharing options...
AndyB Posted July 13, 2006 Share Posted July 13, 2006 If the id is an autonumber then DON"T EVEN THINK OF CHANGING IT. Record ids are something that should be thought of as an intrinsic part of the inner workings of MySQL and nothing to do with how you display the data. The whole point of a relational database is that you can have table that refer to data in other tables and id is that reference.Why can't you simply display them in alphabetical order (ORDER by restaurant_name for example)? Quote Link to comment Share on other sites More sharing options...
fenway Posted July 13, 2006 Share Posted July 13, 2006 AndyB is entirely correct -- don't even dream of touching the auto-increment value. There must be some way to determine the correct order, so you can always do it at run time. Quote Link to comment Share on other sites More sharing options...
akitchin Posted July 13, 2006 Share Posted July 13, 2006 it sounds to me like all you need is a multiple-field ordering clause:[code]ORDER BY restaurant_city ASC, restaurant_name ASC[/code]this will sort by city first, then among each city, by restaurant name.(agreed about the importance of leaving a key be) Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.