Jump to content

Re-Setting the ID number?


nazca

Recommended Posts

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 city
it 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 that
the 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.
Link to comment
Share on other sites

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
Link to comment
Share on other sites

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)?
Link to comment
Share on other sites

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)
Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.