File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Servlets and the fly likes How to query a certain number of data? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Spring in Action this week in the Spring forum!
JavaRanch » Java Forums » Java » Servlets
Bookmark "How to query a certain number of data?" Watch "How to query a certain number of data?" New topic
Author

How to query a certain number of data?

Ken Shamrock
Ranch Hand

Joined: Jan 23, 2002
Posts: 139
For example, if I want to query the maximum latest 1000 records. How can I ?
For (Select Max(column) from XXX where..) can only display the max value of certain column


Thanks everyone who helped me
Andy Bowes
Ranch Hand

Joined: Jan 14, 2003
Posts: 171
The SQL that you need to do this would depend upon the database that you are connecting to.
On Oracle you could do something like:
SELECT * FROM MYTABLE ORDER BY DATE_CREATED DESC WHERE ROWNUM <= 1000
The order by clause will sort the records so that the most recent ones are retrieved first, the where clause will then limit the no of records returned.
I am not sure of the syntax for other DBs but it will be pretty similar if it is supported at all.
Hope this helps
[ March 28, 2003: Message edited by: Andy Bowes ]

Andy Bowes<br />SCJP, SCWCD<br />I like deadlines, I love the whoosing noise they make as they go flying past - Douglas Adams
Ken Shamrock
Ranch Hand

Joined: Jan 23, 2002
Posts: 139
Thanks andy,
but i am using MySQL,
do anyone know if there's any method can work in mysql?thanks
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: How to query a certain number of data?