Win a copy of Programmer's Guide to Java SE 8 Oracle Certified Associate (OCA) this week in the OCAJP forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

inserting data in mysql in sorting order of date column

 
sandy sean
Ranch Hand
Posts: 69
  • Mark post as helpful
  • send pies
  • 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...
 
Zandis Murāns
Ranch Hand
Posts: 174
Java Java ME Opera
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Absolutely impossible.
 
sandy sean
Ranch Hand
Posts: 69
  • Mark post as helpful
  • send pies
  • 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.


 
Martin Vajsar
Sheriff
Posts: 3752
62
Chrome Netbeans IDE Oracle
  • Mark post as helpful
  • send pies
  • 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.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic