Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

alphabetization in a script

Status
Not open for further replies.

mufka

ISP
Dec 18, 2000
587
US
I have a php script that is querying a MySQL database and printing a list of all of the desired fields. The list is alphabetized. If I add new data to the database, the script then doesn't properly alphabetize the data. It keeps all of the entries with the correct letter (all the A's are together) but the items are not alphabetized within each letter (the new entries beginning with A are at the end of the A's). Is there something I can do in the query to get it to alphabetize correctly?
 
Unless you specify an ORDER BY clause in your query, you are not guaranteed the resultset returned by a SELECT query will have any order. SQL is based on set theory and as such does not place any kind of implicit order on the data.


Want the best answers? Ask the best questions! TANSTAAFL!
 
Then there is likely something not quite right about your ORDER BY clause. I have a MySQL dictionary table with more than 100,000 words in it and when I add "aab" to the table then perform a select with the clause "ORDER BY word", "aab" appears exactly where it should.


Want the best answers? Ask the best questions! TANSTAAFL!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top