Jump to content

Archived

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

nazca

RE-SETTING ID - the correct posting

Recommended Posts

I have over 1000 restaurants with an ID attached to each.  The ID is the primary key and not the auto-increment assigned by mysql.
I cannot order by restaurant_name, because of how the data is accessed and displayed -- confusing and wish it was that easy.
I have to first re-set the restaurant-names in alpha order in the database itself and than re-set the ID's to match so that Pizza Hut does not come before Burger King for example.  I have tried to export the data to csv and csv excel, but the error i get everytime is illegal statement terminator or something of that sort.
My only option is to re-set this table, but have no idea how.  I also tried SQLyog, but guess what... phpmyadmin will not allow it.

Hope you can help....

Share this post


Link to post
Share on other sites
The PK and _not_ auto-increment? Huh?  And still, how can you re-set the names if you can't ask the DB to do the same?

Share this post


Link to post
Share on other sites
Funny right, but I am using an application that assigns the ID automatically so a restaurant would have this id assigned..
Hope that clears it up a little.

Share this post


Link to post
Share on other sites
OK... but I'm still unclear about how you can magically figure out the correct order of the names, but MySQL can't.

Share this post


Link to post
Share on other sites
I am not saying Mysql can't, but need to know how mysql can help me to do it. When you input data into mysql it does not automatically alphabetize the restaurants for me. What it does is attached the next ID number to the next restaurant I put in and keeps the ID order correct.

Share this post


Link to post
Share on other sites
Without an example of your data and its structure, this is very confusing.  MySQL doesn't care, and nor you should, about the order (or disorder) in which the data exist in the database.  What's important is being able to retrieve the data sorted in whatever particular order you want it processed or displayed. Without knowing any more about the data, data structure, and your query result requirements, it's hard to know what to suggest as a workable solution to your problem.

Share this post


Link to post
Share on other sites
Are you saying that you cannot sort the restaurant names alphabetically because the names are stored in another table? If so you will probably want to do a join or subquery to get the name from the index and then ORDER BY it. If not I would look at redesigning your database so that they are.

Share this post


Link to post
Share on other sites
Yeah... we'll need to see some sample data, but I find it hard to imagine that some sort of ORDER BY clause won't do the trick.

Share this post


Link to post
Share on other sites

×

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.