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!

Complex Multiple Sort

Status
Not open for further replies.

Pollock

Programmer
Jun 2, 2000
49
CA
I have a data base which contains 2 "date" fields and a character fields( actually about 30 or so other fields, but they do not relate to the problem). Problem I am running into is I need to pull only the first 30 most current date records based on date1 but then display them to the user order by either date2 or the character field. I can get the first 30 records which are correct, but then how do I reorder the now returned result set to reflect sorted by either date2 or the character field. Any help would be appreciated....
 
The dates that initially ordered by are not chosen so a where clause would not work, basically the initial select uses " order by date1 next 30" so I don't have to worry about how far apart the dates are, as I only want the 30 most current and they could be two days apart or 6 months.
 
With regards to database, it is mysql...

Basically what I am looking for goes something like this

Select date1, date2,character1 from table table1 order by

either date2 or character1 but

for the 30 most current date1 records but

there is no date range for date1 I just want the 30 most

recent date1 records....
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top