• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Tim Cooke
  • paul wheaton
  • Paul Clapham
  • Ron McLeod
Sheriffs:
  • Jeanne Boyarsky
  • Liutauras Vilda
Saloon Keepers:
  • Tim Holloway
  • Carey Brown
  • Roland Mueller
  • Piet Souris
Bartenders:

inserting data in mysql in sorting order of date column

 
Ranch Hand
Posts: 69
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi!

I want to store some records in mysql database. records have a date column. i want to store them in sorting order of that date column.

For example, record having date 27/sep/2011 get stored as first row on the top of record having date 26/sep/2011 as:

id_1,name_1,27/sep/2011
id_2,name_2,26/sep/2011

if new records come on future dates they would get inserted on the top.

I DONT want to order them while using select by using order by desc . i want they get inserted into db directly in sorted order.

how to do this???

thanks...
 
Ranch Hand
Posts: 174
Java ME Opera Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Absolutely impossible.
 
sandy sean
Ranch Hand
Posts: 69
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Actually what i want to do is described as follows:

I am implementing pagination using Sql limit in mysql db.Records are needed to get

retrieved from the last row backwards. There are several thousands records in table

and i want to retrieve say 500 records at a time to show up in a page.


"select * from tbl_name order by some_col desc" will retrieve all records. but i

do not want all records, as they are thousands in number.


If i use "select * from tbl_name order by some_col desc limit 500" it will return

last 500 records in descending order.


but i could not find a way to retrieve next block of 500 in reverse direction,

starting from a point where first block have left up.


 
Sheriff
Posts: 3837
66
Netbeans IDE Oracle Firefox Browser
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
What you need is a "pagination query". How such query is constructed depend on the database you are using. I'd suggest to search for mysql pagination query on this site or the web in general, there are countless examples and explanations.
 
Consider Paul's rocket mass heater.
reply
    Bookmark Topic Watch Topic
  • New Topic