File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
A friendly place for programming greenhorns!
Big Moose Saloon
Register / Login
JDBC and Relational Databases
inserting data in mysql in sorting order of date column
Joined: Dec 30, 2010
Sep 27, 2011 05:46:35
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:
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???
Joined: Aug 18, 2009
Sep 27, 2011 05:55:37
Joined: Dec 30, 2010
Sep 27, 2011 10:23:24
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.
Joined: Aug 22, 2010
Sep 28, 2011 02:42:49
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.
I agree. Here's the link:
subject: inserting data in mysql in sorting order of date column
Sorting Strings in Oracle
Help!!! Insert a new record with a field whose value based on existing records
Determining how many records have same field
Dates in MySQL
All times are in JavaRanch time: GMT-6 in summer, GMT-7 in winter
| Powered by
Copyright © 1998-2015