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 strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Multi Sort Issue

Status
Not open for further replies.

Pollock

Programmer
Jun 2, 2000
49
CA
I have a mysql database which has a structure similair to this

date, lastname, givenname,middlename.


problem is i need to take the forty or so most current items in the database based on date, and then i need to sort them by lastname, givenname, middlename..

I can get the first part with order and limit clauses but after i get the result set how do I then sort that result by last,given, first
 
I recommend that you not use the string "date" as a MySQL columnname, as it is a MySQL reserved word.


If you only want the lastest 40 items, just do a sort using all the columns in the order date, last, first, middle.


Finding all records that have the 40 latest date entries is a different matter.

Want the best answers? Ask the best questions!

TANSTAAFL!!
 
Ok, the word date was just an example, it is called something entirely different. The problem i have is sorting in that format does not put the list in alphabetical order. It puts it in date the alpha order, and what i want is the last 40 based on date in alpha order.
 
That is trickier.

The only thing I can think of is to pull the 40 you need out, then resort in the order you need in PHP.

You might try also posting your query question in the MySQL forum.


Want the best answers? Ask the best questions!

TANSTAAFL!!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top